Did you know that Microsoft Access provides an event that fires whenever you open a bound report but all of the underlying data has been filtered out?
For example, consider the Invoice report from the Northwind sample database. The two screenshots below show the report with data (on the left) and without data (on the right):
Improving the User Experience
Showing a report with no data leads to user confusion. They'll often assume–understandably–that there's a bug in the program. However, in most cases, there simply is no data to report.
Handling the No Data event for a report is an easy way to improve the user experience. It's a simple thing, but explicitly telling the user there is nothing to report is a big improvement over showing a mostly empty report with some random error text.
A Simple Improvement
Generating the above user messages does not require custom code for every report. Rather, we can take advantage of the DoCmd.CancelEvent method and add this functionality to our reports without even having to add a code-behind to the report.
Here's the function:
To add it to your report:
The OpenReport Action Was Canceled
Screenshot of Leslie Nielsen as Det. Frank Drebin in The Naked Gun