How to: Close a Report Automatically If It Does Not Contain Any Records
The following example shows how to use the NoData event to cancel opening or printing a report when it has no data. A message box notifying the user that the report has no data is also displayed.
Private Sub Report_NoData (Cancel As Integer)
' Display message to user.
MsgBox "There are no records to report", vbExclamation, "No Records"
' Close the report.
Cancel = True
End Sub