I need to identify where a report selected from a listbox menu of reports has no data to display, then display a "No Records" message before returning to the reports menu list.
When a report is selected from the menu, I call the report with the code:
OpenReport strReportName, acViewPreview
In the called report's NoData event, I use the code:
MsgBox "No Records for Report", vbExclamation, "No Records"
Cancel = True
to (hopefully) bring the user cleanly back to the reports menu.
If the report is run at the report level (not via menu), this works fine. However, when I select the report from the reports menu and it encounters zero records, then it works differently.
If I leave the "Cancel = True" statement in, then I get a "Run-time Error 2501" message, telling me the OpenReport action was cancelled that there is a DoCmd conflict.
If I remove the "Cancel = True" line, I have to approve the messagebox twice, then the report is generated with a "#Error" field on the page.
Appreciate your help.
When a report is selected from the menu, I call the report with the code:
OpenReport strReportName, acViewPreview
In the called report's NoData event, I use the code:
MsgBox "No Records for Report", vbExclamation, "No Records"
Cancel = True
to (hopefully) bring the user cleanly back to the reports menu.
If the report is run at the report level (not via menu), this works fine. However, when I select the report from the reports menu and it encounters zero records, then it works differently.
If I leave the "Cancel = True" statement in, then I get a "Run-time Error 2501" message, telling me the OpenReport action was cancelled that there is a DoCmd conflict.
If I remove the "Cancel = True" line, I have to approve the messagebox twice, then the report is generated with a "#Error" field on the page.
Appreciate your help.