View Full Version : Empty Record Source


ions
04-21-2009, 08:42 AM
Dear MS Access Expert.

Currently, if the user selects report criteria that produces an empty record set, the user gets a report with a bunch of errors.

Instead I don't want to show the report if the underlying recordset is empty.
Instead I just want to notify the user that there are no results for his criteria?

How do I accomplish this.

Thank you

Peter.

pbaldy
04-21-2009, 08:54 AM
Put this in the no data event of the report:

Cancel = True

which will also force you to trap for error 2501 in the code that opens the report, which is a good place for a message box informing the user.

ions
04-22-2009, 09:52 AM
Thanks pbaldy I will give it a try.

Did you read Atlas Shrugged?

PEter.

ions
04-22-2009, 09:57 AM
Where do I trap the error 2501? On Open Event?
Where do you put the Notification (Msgbox)? in the No Data Event?

Thanks

pbaldy
04-22-2009, 09:55 PM
You trap for 2501 in the same event where you have the OpenReport.

You can either put the message box in the No Data event or the error trap; it will fire either way.

I think I've read it 3 times now, over the years. One of my favorites.

ions
04-23-2009, 08:28 AM
Thanks pbaldy.

I am half way done. It is a book that goes right to the ugly truth. :)