Access MVP (2010-2015)

oOo.oOo.oOo.oOo.oOo.oOo

Don’t Open Report if No Data…

You don’t want your Users to open a Report that has nothing to show them, better to give them a message instead.  On the Reports NoData event you can use…

Private Sub Report_NoData(Cancel As Integer)

On Error GoTo Report_NoData_Error

   MsgBox "No data to Display", vbOKOnly, "Report"
   Cancel = True

Report_NoData_Exit:
Exit Sub

Report_NoData_Error:
   If Err.Number = 2501 Then 'the report was cancelled
   Exit Sub
   Else
     MsgBox Err.Number & " - " & Err.Description
Resume Report_NoData_Exit
End If

End Sub

OR 

Private Sub Report_NoData(Cancel As Integer)

   MsgBox "There is no data for this report. Canceling report...", vbInformation, "Report"
   Cancel = -1

End Sub

 1,892 total views,  1 views today

Comments are closed.