storing results of a query into a variable

L

lovey010

I need to store the results of a query into a variable in Access VBA, but i'm
having trouble with the function. This is a sample of the code

Dim x as integer

x = Docmd.openquery("select Query")

The query should return a number
Thanks
 
K

Ken Snell [MVP]

Take a look at DLookup function and use that instead:

Dim x As Integer
x = DLookup("FieldName", "table/query name")
 
Top