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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for empty recordset 2

Status
Not open for further replies.

perrymans

IS-IT--Management
Nov 27, 2001
1,340
US
How do you check to see if a recordset is empty and then do X based on that result?

Thanks. Sean.
 
Have a look at the .BOF and .EOF properties of the Recordset object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
[tt]DCount()[/tt] also may be an alternative.

________________________________________________________
Zameer Abdulla
Help to find Missing people
All cats love fish but fear to wet their paws..
 
Like PHV said:

Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim strSQL As String

strSQL = "SELECT * FROM Orders o WHERE o.[OrderID] = 9999"

Set db = CurrentDb

Set rs = db.OpenRecordset(strSQL)

If (rs.BOF And rs.EOF) Then
MsgBox "rst empty..."
End If

 
Thanks guys, any difference between using DCount or BOF/EOF?

Sean.
 
BOF and EOF apparently use more lines of code, but use less system resources. Depending upon the size of your table DCount could take longer to respond with your answer.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top