I am using version 2003 and here's the scenario:
I am having the devil of a time trying to prevent the following message from popping up when I attempt to open a report with no data. To make my explanation easier, I created a test button and put simple code behind it that duplicates my situation. Here it is:
Private Sub cmdErrorTrapTest_Click()
On Error GoTo ErrorHandler
DoCmd.OpenReport "rptEquipmentMalfunctionsCustom", acViewPreview
ExitHandler:
Exit Sub
ErrorHandler:
If Err.Number = 2501 Then
Resume ExitHandler
Else
MsgBox Err.Description
Resume ExitHandler
End If
End Sub
Here's the code behind the "NoData" event of the report:
Private Sub Report_NoData(Cancel As Integer)
On Error GoTo ErrorHandler
MsgBox "There are currently no records", vbOKOnly,"No Data"
Cancel = True
ExitHandler:
Exit Sub
ErrorHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub
No matter how I manipulate the code, I can't seem to kill the 2501 message. I know I must be doing something ridiculously silly, and not aware of it.
Any help will be so much appreciated.
Mina
I am having the devil of a time trying to prevent the following message from popping up when I attempt to open a report with no data. To make my explanation easier, I created a test button and put simple code behind it that duplicates my situation. Here it is:
Private Sub cmdErrorTrapTest_Click()
On Error GoTo ErrorHandler
DoCmd.OpenReport "rptEquipmentMalfunctionsCustom", acViewPreview
ExitHandler:
Exit Sub
ErrorHandler:
If Err.Number = 2501 Then
Resume ExitHandler
Else
MsgBox Err.Description
Resume ExitHandler
End If
End Sub
Here's the code behind the "NoData" event of the report:
Private Sub Report_NoData(Cancel As Integer)
On Error GoTo ErrorHandler
MsgBox "There are currently no records", vbOKOnly,"No Data"
Cancel = True
ExitHandler:
Exit Sub
ErrorHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub
No matter how I manipulate the code, I can't seem to kill the 2501 message. I know I must be doing something ridiculously silly, and not aware of it.
Any help will be so much appreciated.
Mina
Last edited: