Search code examples
vbams-accessdlookup

DLookup Function in Access returns Type Mismatch Error


I'm trying to use the DLookup function and it keeps giving me a type mismatch error. See code below:

If IsNull(DLookup("[CheckedOutTo]", "tbl_Transaction", "[CheckedInDate]" = Null And "AssetID = " & Forms!frm_NewTransaction!SN))

CheckedOutTo is Short Text, CheckedInDate is a date, and AssetID is a number. I'm not sure what I'm doing wrong or if there's an error in my syntax somewhere. Thanks in advance for the help.


Solution

  • You'll need to include the criteria values as part of the string supplied to DLookup, i.e.:

    If IsNull(DLookup("CheckedOutTo", "tbl_Transaction", "CheckedInDate is null and AssetID = Forms!frm_NewTransaction!SN"))