[AccessD] return query result into variable

Gustav Brock gustav at cactus.dk
Tue Jul 8 04:39:04 CDT 2003


Hi Sander

The quick method is to use DLookup:

  intNewProjectID = DLookup("[TheField]", "qryNewProjectID")

This will fail for an empty output.
If this can happen use:

  intNewProjectID = Nz(DLookup("[TheField]", "qryNewProjectID"), 0)

/gustav


> i'm using A2k. I need to return the value of a query
> into a variable but I cannot rememeber/find the
> correct syntax.

> I've got a query: qryNewProjectID. It returns ONE
> number.

> I want something like this:
> dim intNewProjectID as Integer
> intNewProjectID = docmd.runquery "qryNewProjectID"
> msgbox intNewProjectID
> How do I do this?



More information about the AccessD mailing list