Dlookup syntax with number variable and date () (1 Viewer)

latex88

Registered User.
Local time
Today, 12:20
Joined
Jul 10, 2003
Messages
198
Needing help with syntax involving a number type variable and date () as conditions.

Below does work for me.
dlookup ("MyField", "MyTable", "MyField2" = & numVariable1 and MyField3 = date () )
 

pr2-eugin

Super Moderator
Local time
Today, 18:20
Joined
Nov 30, 2011
Messages
8,494
I always refer to 'DLoopUp Usage Samples', for getting this right.. The result should be something along the lines of..
Code:
DLookUp("yourField", "yourTableName", _
        "yourNumberField = " & numVar [COLOR=Red][B]& "[/B][/COLOR] AND yourDateField =[COLOR=Red][B] #" &[/B][/COLOR] Date()[COLOR=Red][B] & "#"[/B][/COLOR])
 

latex88

Registered User.
Local time
Today, 12:20
Joined
Jul 10, 2003
Messages
198
Thank you Paul. Your code worked beautifully.
 

latex88

Registered User.
Local time
Today, 12:20
Joined
Jul 10, 2003
Messages
198
Paul,
I tried to refer to the link you gave me to come up with the syntax for the below scenario with three conditions, but keep failing. I'd appreciate it if you can help me again.

DLookUp("MyField", "MyTableName", "MyNumericField = " & numVar AND "MyTextField = 'No'" AND MyDateField = #" & dateVar & "#")
 

pr2-eugin

Super Moderator
Local time
Today, 18:20
Joined
Nov 30, 2011
Messages
8,494
You missed a concatenation operator after the numVar and added a double quote after AND whihc is not required.. So change it as..
Code:
DLookUp("MyField", "MyTableName", "MyNumericField = " & numVar [COLOR=Red][B]& " [/B][/COLOR]AND MyTextField = 'No' AND MyDateField = #" & dateVar & "#")
 

latex88

Registered User.
Local time
Today, 12:20
Joined
Jul 10, 2003
Messages
198
Thank you, thank you. I just can't seem to get it.
 

pr2-eugin

Super Moderator
Local time
Today, 18:20
Joined
Nov 30, 2011
Messages
8,494
Hello Latex88, just remember this.. Any variable needs to be concatenated with the Criteria.. If they are direct values like 'No' in the above statement, then it does not have to.. just variables, by using the ampersand operator.. Joining many criteria would be tricky at times, but you will get the hang of things, as times goes on.. :)
 

Users who are viewing this thread

Top Bottom