How to pass a value to a variable

S

sjw

I have a query that gets a value from a table. How do I pass that value to a
variable?
 
J

John Vinson

I have a query that gets a value from a table. How do I pass that value to a
variable?

With DLookUp:

variable = DLookUp("[fieldname]", "[queryname]")

This assumes that you're only interested in one field from the query,
and that the query returns only one record; DLookUp will return the
first value that it finds if the query has multiple records.

John W. Vinson[MVP]
 
S

sjw

Thanks John!

John Vinson said:
I have a query that gets a value from a table. How do I pass that value to a
variable?

With DLookUp:

variable = DLookUp("[fieldname]", "[queryname]")

This assumes that you're only interested in one field from the query,
and that the query returns only one record; DLookUp will return the
first value that it finds if the query has multiple records.

John W. Vinson[MVP]
 
Top