dlookup with multiple criteria

cpampas

Registered User.
Local time
Yesterday, 18:36
Joined
Jul 23, 2012
Messages
221
Hello,
I do have this Dlookup function that works, in case that [win] is a control in my form :

Code:
=Nz(Dlookup("[apostaid]";"tblApostasTemp";"[bookieID]=" & [Forms]![frmApostas]![bookerID] & " AND [jogo]= '" & [jogo] & "'" & " AND [resultado]= '" & [win] & "'");"X")

I want to change it because the value [win], is actualy a string "win", so I tried the following

Code:
=Nz(Dlookup("[apostaid]";"tblApostasTemp";"[bookieID]=" & [Forms]![frmApostas]![bookerID] & " AND [jogo]= '" & [jogo] & "'" & " AND "[resultado]=‘win’”);"X")

How can I make this work ?
 
It looks OK to me (am I missing something? tired eyes), assuming a semicolon is your machine's proper delimiter, except the quotes at the end look a little funky, like microsoft word quotes.

You refer to [jogo] as if it's both a form control and a table column. is that correct? If so maybe differentiate it...
 
Use a single quote either side of the string variable or three double quotes should the variable itself contain a single quote.
If it is a date use # either side.

As mentioned, quotes character is wrong. Use the same ones you used for jogo
 
Code:
... & " AND "[resultado]=‘win’”);"X")


Misplaced double quotes prior to [resultado]. And then you're closing double quotes after win look wrong type.
 
Or just take off the double quote immediately prior to [resultado].
 
Telling us the error message might have helped. Looks to me like a syntax error

=Nz(Dlookup("[apostaid]";"tblApostasTemp";"[bookieID]=" & [Forms]![frmApostas]![bookerID] & " AND [jogo]= '" & [jogo] & "'" & " AND [resultado]='win'");"X")

You had an extra " after the second AND
 
you are right the single quotes were not the correct character, and also the extra quote after the second AND
now everything is working fine
Many thanks
 
you are right the single quotes were not the correct character, and also the extra quote after the second AND
now everything is working fine
Many thanks
We were glad to help - happy to hear it's working now. :)
 

Users who are viewing this thread

Back
Top Bottom