Empty Reports

  • Thread starter Thread starter DS
  • Start date Start date
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
 
Back
Top