Error event

Occurs when a control detects an error and cannot return the error information to a calling program.

Syntax

For MultiPage: Private Subobject _Error(indexAs Long, ByValNumberAs Integer, ByValDescriptionAs MSForms.ReturnString, ByValSCodeAs SCode, ByValSourceAs String, ByValHelpFileAs String, ByValHelpContextAs Long, ByValCancelDisplayAs MSForms.ReturnBoolean)

For other controls: Private Subobject _Error( ByValNumberAs Integer, ByValDescriptionAs MSForms.ReturnString, ByValSCodeAs SCode, ByValSourceAs String, ByValHelpFileAs String, ByValHelpContextAs Long, ByValCancelDisplayAs MSForms.ReturnBoolean)

The Error event syntax has these parts:

Part Description
object Required. A valid object name.
index Required. The index of the page in a MultiPage associated with this event.
Number Required. Specifies a unique value that the control uses to identify the error.
Description Required. A textual description of the error.
SCode Required. Specifies the OLE status code for the error. The low-order 16 bits specify a value that is identical to the Number argument.
Source Required. The string that identifies the control that initiated the event.
HelpFile Required. Specifies a fully qualified path name for the Help file that describes the error.
HelpContext Required. Specifies the context ID of the Help file topic that contains a description of the error.
CancelDisplay Required. Specifies whether to display the error string in a message box.

Remarks

The code written for the Error event determines how the control responds to the error condition.

The ability to handle error conditions varies from one application to another. The Error event is initiated when an error occurs that the application is not equipped to handle.

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.