Help with Dlookup

Dr Peter Klomp

New member
Local time
Today, 23:39
Joined
Jun 23, 2020
Messages
11
Hello
Can anyone please tell me why the last part of this VBA code I'm using for MS Access is not working?

FirstName = DLookup("[EEFirstName]", "qryDelegateBookingDetails", "[Delegate] = True And [InvoiceNow] = True And [Attended] <> ' "Cancelled" ' ")

The problem seems to be the string quotes.

Thank you
Peter
 
Usually in a Dlookup your criteria ensures uniqueness ( e.g. [ID]=273, [EventDate]=2/2/2023, etc). Without knowing your data it seems that query could have multiple records that meet your Dlookup criteria. How do you know the Dlookup is returning the correct EEFirstname of the record you want?
 
I tend to put the criteria into a string variable for domain functions if not a single simple criteria.
Then I can debug.print them to see if I have the syntax correct.
Then when correct, I can use that in the function.
Plus, if you cannot see the error, you can copy and paste here or eslewhere, so someone can point out the error.?
 

Users who are viewing this thread

Back
Top Bottom