Function dlookup (strFieldName, strTableName, strWhere, objConn) 'in reference Access VBA Dlookup function' due to the different environments, plus ObjConn parameters come directly transferred directly Adodb.connection Dim strsql Dim rs Set rs = server.CreateObject ( "adodb .recordset ") 'below to call an external custom function checksql () strFieldName = checksql (strFieldName) If strWhere <>" "Then strWhere =" where "& strWhere End If strsql =" select "& strfieldname &" from "& strtablename &" "& strwhere 'Debugstop Strsql On Error Resume Next Rs.open Strsql, Objconn, 1, 1 IF Err.Description Response.End () end if if rs.eof and rs.bof the dlookup = "" Else 'To call a custom function NZ' For details, please refer to the information DLOOKUP = NZ (RS (StrfieldName), "") end if rs.closend function in Access VBA Help.