A family of Microsoft relational database management systems designed for ease of use.
What does the code look like?
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Microsoft Access - I have an Error Trap that catches a First Error, but on a second Error Number 2501 Opening a Report, that has a No Data routine and cancels the opening of the Report, this second error is not trapped and I cannot seem to figure out how to get it to a Error Trap Routine.
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
I have an Error Trap to catch Err.Number 3021 so I get the Last Record that ran, it refers to a GoTo..., this works fine when there is data. When it goes to the GoTo it Opens a Report, when there is No Data, the Report has the NoData Event that tells the End User there is No Records for that user. In this Sub it also has a CancilEvent, when it Returns to the Calling Sub Rutine is when the error occurs, it stops on the OpenReport command with the Error Number 2501. It will not go to the Error Trap, it does a Popup.
Do you get this error in a procedure that opens the report using DoCmd.OpenReport?
If so, use something like this:
Private Sub cmdOpenReport_Click()
On Error GoTo ErrHandler
DoCmd.OpenReport ReportNsme:="MyReport", View:=acViewPreview
Exit Sub
ErrHandler:
Select Case Err.Number
Case 2501
' Opening the report was canceled; we can ignore this
Case Else
' Show the error
MsgBox Err.Description, vbExclamation
End Select
End Sub