On Error Statements

You can use the "On Error" statement to specify which type of error handler to use when a run-time error occurs.

On Error { GoTo [ line | 0 | -1 ] | Resume Next } 

There are 3 choices:
1) On Error GoTo 0 - this interrupts your code with a dialog box. This is the default when no error handler is specified.
2) On Error Resume Next - this ignores all run-time errors. This is not recommended.
3) On Error GoTo LineLabel - this lets you provide a custom error handler.


On Error GoTo 0

This is the default error handler which interrupts execution and displays a dialog box.

On Error GoTo 0 

Disables enabled error handler in the current procedure and resets it to Nothing. more


On Error Resume Next

On Error Resume Next 

This statement allows execution to continue when a run-time error occurs. more


On Error GoTo LineLabel

On Error GoTo LineLabel 
LineLabel:

Execution jumps to the line label when an error occurs. more


On Error GoTo -1

Clears the error handling allowing you to define another error trap. more

On Error GoTo -1 

Resume Statement

Allows you to resume execution after a run-time error occurs. more

On Error Resume 
On Error Resume Next
On Error Resume LineLabel

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext