Problem with DLookUp function

A

Arvin Villodres

Good Day to everyone.

How can I set this criteria in a DLookUp Function?

Min >= tempVar >= Max

I used this code but it didn't work.

tempVar = var1 + var2

Equi = DLookup("[Result]", "tblResult", "[Min]>= " &
tempVar And "[Max]<= " & tempVar)

Thank you very much to all.
 
J

John Vinson

Good Day to everyone.

How can I set this criteria in a DLookUp Function?

Min >= tempVar >= Max

I used this code but it didn't work.

tempVar = var1 + var2

Equi = DLookup("[Result]", "tblResult", "[Min]>= " &
tempVar And "[Max]<= " & tempVar)

Thank you very much to all.

The third argument needs to be a valid SQL WHERE clause (without the
WHERE) *after* you've concatenated all the pieces. The problem is that
you have the word AND outside the quotes. Try

Equi = DLookup("[Result]", "tblResult", "[Min]>= " &
tempVar & " And [Max]<= " & tempVar)

Thus if tempVar is equal to 42, the concatenated string would be

[Min]>= 42 And [Max]<= 42
 
G

Guest

The AND also needs to be in the string condition. Try this:

Equi = DLookup("[Result]", "tblResult", "[Min]>= " &
tempVar & " And [Max]<= " & tempVar)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top