Access MVP (2010-2015)


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

Exit Sub

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

End Sub


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.