Getting number of records returned by query

oni29

Registered User.
Local time
, 05:51
Joined
Mar 2, 2007
Messages
12
I'm using the following code to run queries:

--
Dim stQuery As String
stQuery = 'INSERT SQL HERE'

DoCmd.SetWarnings False
DoCmd.OpenQuery stQuery, acNormal, acEdit
DoCmd.SetWarnings True
--

Is there a way of seeing how many records the query returns?
 
You can use the Execute method of a Database object to run the action query (a Delete, Append, Update or Make-table query) and read its RecordsAffected property.

In ADO or DAO:-
Dim db As Object
Dim stQuery As String

stQuery = "queryName"

Set db = CurrentDb
db.Execute stQuery
MsgBox db.RecordsAffected


In DAO, we can also use:-
Dim db as DAO.Database​
.
 

Users who are viewing this thread

Back
Top Bottom