I have a form in the Access 2013 program that allows the user to input selection criterion for a report. In some cases there will be no data matching their selection criterion.
To handle that situation I have logic in the report 'NoData' event.
Private Sub Report_NoData(Cancel As Integer)
MsgBox "No Data Meets Selection Criterion"
Cancel = True
If I don't cancel the report it thorws and errror in the logic referencing one of the fields on the report.
The above logic work and the report is cancelled but I now get a 'Runtime Error 2501. The Open Report Action was cancelled' error on the statement that called the report:
DoCmd.OpenReport newReportName, acViewPreview, , , acDialog
I realize I can put error handling right after the 'OpenReport' command but I will have to do this everywhere I call a report in the application.
Is there a cleaner way of handling this situation?