dlookup with multiple criteria (1 Viewer)

cpampas

Registered User.
Local time
Today, 02:29
Joined
Jul 23, 2012
Messages
218
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 ?
 

Isaac

Lifelong Learner
Local time
Today, 02:29
Joined
Mar 14, 2017
Messages
8,738
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...
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:29
Joined
Sep 21, 2011
Messages
14,037
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
 

plog

Banishment Pending
Local time
Today, 04:29
Joined
May 11, 2011
Messages
11,611
Code:
... & " AND "[resultado]=‘win’”);"X")


Misplaced double quotes prior to [resultado]. And then you're closing double quotes after win look wrong type.
 

Isaac

Lifelong Learner
Local time
Today, 02:29
Joined
Mar 14, 2017
Messages
8,738
Or just take off the double quote immediately prior to [resultado].
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:29
Joined
Feb 19, 2002
Messages
42,970
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
 

cpampas

Registered User.
Local time
Today, 02:29
Joined
Jul 23, 2012
Messages
218
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
 

Isaac

Lifelong Learner
Local time
Today, 02:29
Joined
Mar 14, 2017
Messages
8,738
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

Top Bottom