test for Null query result in VBA

M

MJH

I created a queary in Access 2003. How do I test for a possible Null result
from running the query, i.e. no records, using VBA code?

thanks
 
K

Ken Snell [MVP]

One way is to use the DCount function to see how many records are returned
by the query. A value of 0 means no records.

NumberOfRecordsReturned = DCount("*", "QueryName")
 
W

Wayne Morgan

Another way would be if you are creating a recordset using that query, test
for BOF And EOF of the recordset. If you're at both the beginning and end of
the recordset at the same time then there are no records in the recordset.

If rst.BOF And rst.EOF Then
'no records
Else
'continue
End If
 
Top