On Error GoTo not working

ML!

Registered User.
Local time
Today, 02:59
Joined
May 13, 2010
Messages
83
Why would error trapping not be working in my app?

I'm using Access 2007. To try to track the problem down, I created a dummy form and wrote some simple code on a cmd button and forced a div by 0 error. The standard VBA msg box is displayed with run-time error 11. The Error function seems to be ignored, it doesn't catch it.

Code:
Private Sub cmdOK_Click()
On Error GoTo Err_cmdOK_Click
 
   Debug.Print 1 / 0
 
Exit_cmdOK_Click:
    Exit Sub
Err_cmdOK_Click:
    MsgBox "Don't divide by zero"
    Resume Exit_cmdOK_Click
 
End Sub

I may have caused this by changing a global setting when I was trying to get rid of a Return without GoSub error but, if I did, I don't remember what it was.

Anyone have any ideas why this isn't working?

TIA
 
I just tried your code and received this message: Don't divide by zero
 
Hi ML

In the VB editor window, go to Tools > Options > General tab.

Make sure you don't have "Break on all errors" selcted in the "Error trapping" section.

--
Graham
 
Hey Graham!

Thanks so much. I do remember changing that now. You've saved me a whack of time!

ML
 

Users who are viewing this thread

Back
Top Bottom