Test if query contains no records...

Steff_DK

Registered User.
Local time
Today, 18:51
Joined
Feb 12, 2005
Messages
110
I want to test if no records match the strSQL query.
How is that done??

I have:
Code:
strSQL = "SELECT bla bla...."
Form_frmnavnogby.RecordSource = strSQL
'HERE it goes wrong...
If Form_frmnavnogby.RecordSource = Empty Then
Msgbox "There where no matching records"
Form_frmnavnogby.RecordSource = AnotherstrSQL
...
 
You can test that from any recordset.

The form has a recordset...

If Me.Form.Recordset.RecordCount >0 then
'records exist
else
'no records
End if
 
If you are using datareader u can test with

if dr.HasRows = false then
MsgBox("No rows returned")


--deepthi
 

Users who are viewing this thread

Back
Top Bottom