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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top