I have a way to open a report, but if there is no data current when I open the report it gives me a run time error and crashes.
The code I am using to call
Under the report that is being called I have the "On No Data" Property set to the following code:Code:Private Sub cmbPrintManhole_Click() Dim str1 As String If Me.cmbArea = "ALL" Then DoCmd.OpenReport "PEC_StormDrainManholeReport", acViewPreview, , "[Manhole Number (12)] <> """"" Else str1 = Me.cmbArea DoCmd.OpenReport "PEC_StormDrainManholeReport", acViewPreview, , "[Area] ='" & str1 & "'" End If End Sub
When I click the button to Open the report in print view it brings up a message box like it is suppose to then after I click OK it brings up a Run-time error'2501': The OpenReport action was canceled.Code:Private Sub Report_NoData(Cancel As Integer) MsgBox "No records in current selection" Cancel = True End Sub
Any help would be appreciated, thank you.


Run-time error '2501' The OpenReport action was canceled
Reply With Quote

