Functional function DLookup (strfieldname, strTableName, strwhere, objconn)
' Refer to the DLookup function in Access VBA
' Because the environment is different, add the objconn parameter, direct adodb.connection direct redeployment to
Dim strSQL
Dim RS
Set rs = server. CreateObject ("Adodb.recordset")
' Next to call a custom function outside the 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 <> 0 Then
Response.Write Err.Description
Response.End ()
End If
If Rs. EOF and Rs. BOF Then
DLookup = ""
Else
' To call a custom function NZ
' For details, refer to the information in ACCESS VBA help
DLookup = Nz (rs (strfieldname), "")
End If
Rs. Close
End Function