Empty report condition

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

Guest

What is the correct way to handle the 'empty report condition'?
Currently, I have an event procedure set up which displays a message.
However, the procedure that opens the report also has an 'on error' handler
and this is being triggered and so shows a second message.
 
"the procedure that opens the report also has an 'on error' handler" should
ignore error number 2501.
 
What is the correct way to handle the 'empty report condition'?
Currently, I have an event procedure set up which displays a message.
However, the procedure that opens the report also has an 'on error' handler
and this is being triggered and so shows a second message.

Code the Report's OnNoData event:

MsgBox "Sorry, no records to report on."
Cancel = True

The above will generate error 2501 if you have opened the report from
an event.
Trap the error in that event:

On Error Goto Err_Handler
DoCmd.OpenReport "ReportName", acViewPreview
Exit_This_Sub:
ExitSub
Err_Handler:
If Err = 2501 Then
Else
MsgBox "Error #: " & Err.Number & " " & Err.Description
End If
Resume Exit_This_Sub
 

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

Back
Top