Query Results

  • Thread starter Thread starter Jarod
  • Start date Start date
J

Jarod

Is there a way to check(in VBA) whether the Query just
executed through VBA, has(returns) any records?
 
One way to do it would be as follows:

If <DAO Recordset Object Name>.RecordCount > 0 then
do something
else
do something else
End If
 
The only type of Query that returns Record is the Select Query so I assume
you are talking about Select Query and the usual way to get the return is
the Recordset object. For the Recordset, you have the RecordCount property
that you can use.

For DAO Recordset, you must populate the Recordset fully (using MoveLast) to
get the correct RecordCount. For ADO Recordset, the RecordCount may not
give the actual Record count depending on which type of Recordset you
created.
 
Back
Top