Occurs only as the result of a data access error that takes place when no Visual Basic code is being executed.
Syntax
Private Sub object_Error ([index As Integer,] dataerr As Integer, response As Integer)
The Error event syntax has these parts:
Part | Description |
object | An object expression that evaluates to an object in the Applies To list. |
index | Identifies the control if it's in a control array. |
dataerr | The error number. |
response | A number corresponding to the response you want to take, as described in Settings. |
Settings
The settings for response are:
Constant | Value | Description |
vbDataErrContinue | 0 | Continue |
vbDataErrDisplay | 1 | (Default) Display the error message |
Remarks
These constants are listed in the Visual Basic (VB) object library in the Object Browser.
You usually provide error-handling functionality for run-time errors in your code. However, run-time errors can occur when none of your code is running, as when:
If an error results from one of these actions, the Error event occurs.
If you don't code an event procedure for the Error event, Visual Basic displays the message associated with the error.
Errors that occur before the Form_Load event, are not trappable and do not trigger the Error event. For example, if at design time you set the properties of the Data control to point to an unknown database table an untrappable error results.