Error 2501 when cancelling msgbox

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
----------------------------------
 
W

Wayne Morgan

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top