Problem with DLookUp function

  • Thread starter Thread starter Arvin Villodres
  • Start date Start date
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.
 
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
 
The AND also needs to be in the string condition. Try this:

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