OnNoData System Error Msg

S

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
 
F

fredg

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
 
O

Ofer

When there is no data, how did you close the report?

In the Report_NoData just put
Cancel = True
after the msgbox
 
S

Sandy

Thanks for your response, Fred!

I tried the error trapping and still got the error.

Any other suggestions?
 
S

Sandy

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?
 
F

fredg

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.
 
R

rajeev

I also faced the same problem after puting a MsgBox and Cancel = tru
in the OnNoData . I solved the problem by opening the report through
macro, attaching this code Docmd RunMacro " mOpenMyReport"

- Rajee
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top