Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Test recordset for emptiness 1

Status
Not open for further replies.

projecttoday

Programmer
Joined
Feb 28, 2004
Messages
208
Location
US
How do test a recordset if it's empty or not? Let's say you have

SQLstr = "SELECT ...
Set rs = db.OpenRecordset(SQLstr)
rs.MoveFirst

If rs is empty you will get an error on rs.MoveFirst. How do you test for that?


Robert
 
Code:
if rs.bof and rs.eof
msgbox "Recordset empty!"

else
rs.MoveFirst
end if
 
Forgot the "Then".
Code:
if rs.bof and rs.eof Then
   msgbox "Recordset empty!"
else
   rs.MoveFirst
end if

Duane MS Access MVP
Now help me support United Cerebral Palsy
 
You may also test the rs.RecordCount property.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top