Angela Wang
Angela Wang

Reputation: 3

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.

Upvotes: 0

Views: 275

Answers (2)

Vlado
Vlado

Reputation: 888

I think you need to do it this way:

If IsNull(DLookup("CheckedOutTo", "tbl_Transaction", "CheckedInDate is Null and AssetID = " & Forms!frm_NewTransaction!SN)) Then ...

Upvotes: 0

Lee Mac
Lee Mac

Reputation: 16015

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"))

Upvotes: 1

Related Questions