Displaying MsgBox

  • Thread starter Thread starter Kerry O'Neill
  • Start date Start date
K

Kerry O'Neill

When I preview a report and there are no matching records
found I want to display a Msgbox that tells the user that
there was no records found and then closes the report when
the user clicks an ok button on the msgbox. I don't have a
clue how to do this, I'm an inexperienced access user!
 
Kerry said:
When I preview a report and there are no matching records
found I want to display a Msgbox that tells the user that
there was no records found and then closes the report when
the user clicks an ok button on the msgbox. I don't have a
clue how to do this, I'm an inexperienced access user!

You need to use a little code in the report's NoData event:

MsgBox "There were no records found", . . .
Cancel = True

See Help for all of MsgBox's options.

You will then get your message box, but another message box
will also pop up telling you that the report was canceled.
You can avoid the second message if you use a form button's
click event (the wizard will generate the code for you) to
open the report and add error trapping to ignore error 2501.
 
Back
Top