conditional macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If a filter returns no records I would like a message box to appear to say
'No records found'. Do I do this with a conditional macro and what would the
syntax be?
Thanks
 
JOJO,

Use something like:

***
Dim db As Database
Dim Rst As Recordset

Set db = CurrentDB()
Set Rst = db.OpenRecordset("YOURTABLENAME")
If Rst.RecordCount = 0 Then 'test for the existance of any records
Msgbox ("No records found")
Exit Function
End If

'The rest of your code to be executed if records exist
***


Don't forget to include error handling in your procedure.

Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top