Error 2501 when cancelling msgbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm working in Access 2002 and have written the following simple code to run a report when the user clicks a button on a form. The Access-created msgbox displays a "cancel" button which, if chosen, displays the 2501 error message. As you can see, I have included an error handler but Access appears to ignore it and continues displaying the error message. If I hit "debug", I'm taken to the DoCmd line of code. Any advice about what I'm doing wrong

Thanks, very much

-------------------------
Private Sub SingleAcctBalBySpecDate_Click(
On Error GoTo Err_SingleAcctBalBySpecDate_Clic

Dim stDocName As Strin

stDocName = "rpt_SummaryOfCostsAndExpensesByAcctToDate
DoCmd.OpenReport stDocName, acPrevie

Exit_SingleAcctBalBySpecDate_Click
Exit Su

Err_SingleAcctBalBySpecDate_Click
'If action was cancelled by the user, don't display an error messag
Const conErrDoCmdCancelled = 250
If (Err = conErrDoCmdCancelled) The
Resume Exit_SingleAcctBalBySpecDate_Clic
Els
MsgBox Err.Descriptio
Resume Exit_SingleAcctBalBySpecDate_Clic
End I

End Su
----------------------------------
 
If (Err = conErrDoCmdCancelled) Then

Try

If (Err.Number = conErrDoCmdCancelled) Then


--
Wayne Morgan
Microsoft Access MVP


mlgraham said:
I'm working in Access 2002 and have written the following simple code to
run a report when the user clicks a button on a form. The Access-created
msgbox displays a "cancel" button which, if chosen, displays the 2501 error
message. As you can see, I have included an error handler but Access
appears to ignore it and continues displaying the error message. If I hit
"debug", I'm taken to the DoCmd line of code. Any advice about what I'm
doing wrong?
 
Back
Top