View Full Version : Query result in VBA


Magster
03-23-2009, 08:28 AM
Hi all,

I have a query which provides a count of the rows meeting my criteria. I want to call this query from VBA and capture the count. I know that I can create a recordset using this query and check the recordcount of the recordset. But...

What I'd like to know is there a quick way to get the query's result directly into a variable without creating a recordset since I'm not interested in the recordset itself? If so, would you provide the syntax of the call to the query in VBA?

Thanks so much!

M

KenHigg
03-23-2009, 08:42 AM
Can you use the dcount() function for this?

Magster
03-23-2009, 08:48 AM
Hi Ken - and thanks for the quick reply. I never heard of this function, but from what I see on the help documentation, I think it will work perfectly! Thanks very much and have a great day!

Magster
03-23-2009, 09:21 AM
I spoke too soon - my query has a parameter and the domain of the dCount method states that no parameter queries are allowed. So I guess I'm back to the recordcount method of the recordset.

Thanks Ken for the suggestion. I'm sure that I'll make use of this function in the futuer!