Returning a Query's RecordCount to VBA

whdyck

Registered User.
Local time
Today, 13:31
Joined
Aug 8, 2011
Messages
169
I'm using Access 2003.

Probably a bonehead question here: How can I run a query within VBA and capture the recordcount of the result set?

I'd like to use the CurrentDb.Execute function, but it seems to work only for "action" type queries (Inserts, Updates, or Deletes).

Thanks for any help you can give.

Wayne
 
Usually I have found that in the Recordset object containing the query results.

I suggest you place a breakpoint and watch on the object the .Execute returns and peek around inside it.

I do not use CurrentDb.Execute ever, so not sure what type of object that returns.
 
This will give you the record count:
Code:
Dim i As Integer
i = DCount("*", "[B][COLOR=red]NameOfYourQuery[/COLOR][/B]")
Substitute NameOfYourQuery with the name of your query.
 

Users who are viewing this thread

Back
Top Bottom