OnNoData System Error Msg

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello -

I put a messagebox in the Sub Report_NoData indicating no data for the
selected criteria. It works great, except that after my messagebox comes up,
another one comes up which says "The OpenReport action was cancelled."

I tried to turn it off by setting warnings to off before and after the
msgbox, but it still pops up.

Any suggestions on how to get rid of this?


Sandy
 
Hello -

I put a messagebox in the Sub Report_NoData indicating no data for the
selected criteria. It works great, except that after my messagebox comes up,
another one comes up which says "The OpenReport action was cancelled."

I tried to turn it off by setting warnings to off before and after the
msgbox, but it still pops up.

Any suggestions on how to get rid of this?

Sandy

That message is not a Warnings message, it's an error message.
You need to trap that error in the code you use to open the report:

On Error GoTo Err_Handler
DoCmd.OpenReport "ReportName", acViewPreview
Exit_Sub:
Exit Sub
Err_Handler:
If Err = 2501 then
Else
MsgBox "Error #: " & Err.Number & " " & Err.Description
End If
Resume Exit_Sub
 
When there is no data, how did you close the report?

In the Report_NoData just put
Cancel = True
after the msgbox
 
Thanks for your response, Fred!

I tried the error trapping and still got the error.

Any other suggestions?
 
Hi Ofer -

Thanks for responding! I already had "cancel = true" in my code.

I tried Fred's suggestion and that didn't work. Any other thoughts?
 
Thanks for your response, Fred!

I tried the error trapping and still got the error.

Any other suggestions?

Precisely where did you place the code?
It goes into the form event that you use to open the report, not in
the report.
 
Back
Top