Empty Reports

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

Anyway to bring up a messagebox if a report contains no info?
Thanks
DS
 
Anyway to bring up a messagebox if a report contains no info?
Thanks
DS

Code the Report's OnNoData event:
MsgBox "Sorry, no records to report on."
Cancel = true

The above will generat 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
 
fredg said:
Code the Report's OnNoData event:
MsgBox "Sorry, no records to report on."
Cancel = true

The above will generat 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
Great! Thank you, It works!
DS
 

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