Dlookup with Mutiple Criteria

JayAndy

Registered User.
Local time
Today, 12:38
Joined
Jan 13, 2016
Messages
31
Hi All

The below syntax l have created from the information on the web but still get a Syntax error.

DLookup("ID", "Bill", "Customer = " & Forms!Bills!Customer _
& " AND Date = '" & Forms!Customer!Today & "'")

What am l doing wrong.

Thanks
 
dont breakup the command using underscore
be sure to use brackets to show fields (as opposed to functions...date)
you dont need the full path of field if you are in the form....if in a query DONT use dlookup.
use # as a delimiter for dates, not quotes.

DLookup("ID", "Bill", "[Customer]=" & me.Customer & " AND [Date] = #" & me.Today & "#")
 
First of all rename your [Date] field to something else - Date is a reserved word and will cause you no end of pain.

In any vba criteria you need to enclose any text based fields in quotes ' ' and dates must be enclosed in the hash delimiter #

So assuming Customer is text and we rename your date field to MyDate then it should be
Code:
DLookup("ID", "Bill", "Customer = '" & Forms!Bills!Customer  "' AND MyDate = #" & Forms!Customer!Today & "#")
 
First of all rename your [Date] field to something else - Date is a reserved word and will cause you no end of pain.

In any vba criteria you need to enclose any text based fields in quotes ' ' and dates must be enclosed in the hash delimiter #

So assuming Customer is text and we rename your date field to MyDate then it should be
Code:
DLookup("ID", "Bill", "Customer = '" & Forms!Bills!Customer  "' AND MyDate = #" & Forms!Customer!Today & "#")

Thanks but when VBa does like "' AND MyDate = #" Part and comes up with error: Complie error: Expected list separator or )
 
Doh - missed a & out try this
Code:
DLookup("ID", "Bill", "Customer = '" & Forms!Bills!Customer [COLOR="Red"]&[/COLOR] "' AND MyDate = #" & Forms!Customer!Today & "#")
 

Users who are viewing this thread

Back
Top Bottom