Dlookup Multiple Criteria (1 Viewer)

tucker61

Registered User.
Local time
Yesterday, 22:53
Joined
Jan 13, 2008
Messages
321
Still Struggling with another Dlookup for multiple criteria.

My current code which works is

Code:
WhoCharge = Nz(DLookup("Processor", "TblQCPreRetailSuppliers", "Supp_Code='" & Nz(tbSup_Code.Value, "") & "'"), "")

and i want to add another criteria to check if the supplier is live, so tried this code which does not work.

Code:
WhoCharge = Nz(DLookup("Processor", "TblQCPreRetailSuppliers", "Supp_Code='" & Nz(tbSup_Code.Value, "") & "' AND [Live] = True"), "")

The live field is in the same table "TblQCPreRetailSuppliers" and is a yes / no field. (Tick Box)

Do i need to have the field on the Form to look up if they are live or not ?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 06:53
Joined
Feb 19, 2013
Messages
16,603
'does not work' is not helpful, is the problem a wrong result? an error message? something else? If a wrong result, show the parameters you are using (tblSupCode in this case), the result you get and the record which should have been a right result. If an error, what is the error message?

Do i need to have the field on the Form to look up if they are live or not ?
Not in this case, only if you wanted the form to provide a True/False value to be used in your lookup

On the face of it, I don't see anything wrong with the code so suspect a wrong result - so provide the information requested for a wrong result
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:53
Joined
Sep 21, 2011
Messages
14,221
Put the criteria into a string variable, debug.print that. When you get it right, use that in the Dlookup()

I know I sound like a stuck record saying this all the time, but it works, believe me. :)
 

Users who are viewing this thread

Top Bottom