On Error Instruction
Syntax
On Error GoTo 0 -or- On Error GoTo label -or- On Error Resume Next
Group
Description
Form 1 - Disables the error handler (default).
Form 2 - Sends error conditions to an error handler.
Form 3 - Error conditions continue running at the next statement.
On Error sets or disables the error handler. Each user defined procedure has its own error handler. The default is to terminate the macro on any error. The Err object properties are set whenever an error occurs. When an error occurs and the error handler is executing any further errors, the macro terminates, unless the Err object is cleared.
Example
Sub Main On Error Resume Next Err.Raise 1 Debug.Print "RESUMING, Err="; Err On Error GoTo X Err.Raise 1 Exit Sub X: Debug.Print "Err="; Err Err.Clear Debug.Print "Err="; Err Resume Next End Sub