troubleshooting Question

Handling Report with No Data

Avatar of mlcktmguy
mlcktmguyFlag for United States of America asked on
Microsoft Access
15 Comments2 Solutions118 ViewsLast Modified:
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
'
End Sub

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?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 15 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros