How to get the result of a query into a VB variable?

R

Randi W

Excuse me for my newbie question, but I am working on a form with some event
code, and I would like to put the result of a query into a variable, like
this:

Res = "select count(*) from tableQ"

How do I do that?

Thanks for your help!

Randi W.
 
M

Michel Walsh

Hi,


myVar =DCOUNT("*", "tableQ")


or, in general, using ADO, as example:


myVar = CurrentProject.Connection.Execute("SELECT COUNT(*) FROM
tableQ").Fields(0).Value




Hoping it may help,
Vanderghast, Access MVP
 
Top