Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't trap runtime errors in Access 2000

Status
Not open for further replies.

ClifCamp

Technical User
Jul 24, 2001
23
US
Based on some other threads I read, I tried the following code to trap error 2501, OpenReport Event Cancelled. This is from the NoData event of my report. It also resets the form controls to Null. No matter what code I try, the runtime error msgbox appears with the 'End' and 'Debug' buttons. All of my reference books provided code which didn't work. Any help will be greatly appreciated.

Private Sub Report_NoData(Cancel As Integer)
On Error GoTo Msg_Err

MsgBox "No data matched your criteria.", vbExclamation

DoCmd.CancelEvent

LineNull:
Forms!frmReportParameters![Combo6] = Null
Forms!frmReportParameters![Text10] = Null
Forms!frmReportParameters![Combo0] = Null
Forms!frmReportParameters![Combo2] = Null
Forms!frmReportParameters![Combo4] = Null
Forms!frmReportParameters![Text12] = Null
Forms!frmReportParameters![Combo21] = Null
Forms!frmReportParameters![Combo6].SetFocus
Exit Sub

Msg_Err:
Select Case Err.Number
Case 2501
MsgBox "Report was cancelled."
End Select
Resume LineNull
End Sub
 
Replace

DoCmd.CancelEvent

with

Cancel = True

and you should be fine.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top