Using Variables in lookup function

aqif

Registered User.
Local time
Today, 04:14
Joined
Jul 9, 2001
Messages
158
Hi All
smile.gif


I am using lookup function like this

DLookup(" [Table1]![Field1] ", "Table1", " [Table1]![Field2]= [txtbox1]")

its working fine for me but I want to use a variable name in criteria like

Dim var1 as integer

var1 = 1

DLookup("
![Field1] ", "Table", "
![Field2]= var1")

I have also tried

DLookup(" [Table1]![Field1] ", "Table1", " [Table1]![Field2]= [var1]")

but its not working, rite now I m storing the value in an invisible text box and then referring the name of that text box name in criteria expression. Is there a way to directly use declared variables in criteria expression.

Cheers!
Aqif
 
There are a number of syntactical errors in your function. Here is what it should look like:

DLookup("[FieldName]","TableName","[FieldInTable] = " & Var1)

Take a look at the examples in the Help files under DLookup function for an explanation of the various arguments of the function.

[This message has been edited by Jack Cowley (edited 07-15-2001).]
 
Thanxx....it was of great help to me
smile.gif
 

Users who are viewing this thread

Back
Top Bottom