Err.Clear, On Error Goto, and On Error Resume
do not reset the 'Resume' flag, but they do
wipe out the error object:
Error_Handler:
On Error Resume Next
MsgBox Err.number & ": " & Err.Description
x = 1 / 0 'runtime error here is not ignored (i.e. not "skipped") by
the resume next
Even though they do not reset the 'Resume' flag, they need
to be used with caution if you write an error handling
routine.
(david)
"Matthew Wells" <MW****@FirstByte.net> wrote in message
news:5l***************@newsread3.news.atl.earthlin k.net...
The error handler can only handle one error at a time. So when you
triggered the first error, there is still an active error when you
triggered
the error in Exit_handler. You must first "handle' the error in
err_handler
by using the "resume" statement. If you change "goto exit_handler" with
"resume Next" you'll see it works.
<bo*********@yahoo.com> wrote in message
news:11**********************@j52g2000cwj.googlegr oups.com... I know On Error Resume Next is generally considered lazy. But can
someone tell me why the resume next in Exit_Handler does not seem to
work? It generates the typical unhandled runtime error message from
Access. If I comment out the 1st On Error Resume Next and the x = 1 /
0 on the next line there is no difference, i.e. ther same unhandled
error on the same line. I included these 2 lines of code to
demonstrate that On Error Resume Next does work in some cases. Anyone
know why its "not working" in Exit_Handler?
Private Sub Command44_Click()
Dim x%
On Error Resume Next
x = 1 / 0
On Error GoTo Error_Handler
x = 1 / 0
Exit_Handler:
On Error Resume Next
x = 1 / 0 'runtime error here is not ignored (i.e. not "skipped")
by the resume next
On Error GoTo 0
Exit Sub
Error_Handler:
GoTo Exit_Handler
End Sub