Raise

This method generates a run-time error.

Syntax

object.Raise number, source, description, helpfile, helpcontext

Parameters

object
Required. Always the Err object.
number
Required. Long integer that identifies the nature of the error. Errors are in the range from 0 through 65535. When setting the Number property to your own error code in a class module, you add your error code number to the vbObjectError constant. For example, to generate the error number 1050, assign vbObjectError + 1050 to the Number property.
source
Optional. String expression that names the object or application that generated the error. When setting this property for an object, use the form project.class. If source is not specified, the programmatic identifier of the current project is used.
description
Optional. String expression that describes the error. If unspecified, the value in the Number property is examined. If the value can be mapped to a run-time error code, the string that would be returned by the Error function is used as description. If no error corresponds to the Number property, the following message is used: Application-defined or Object-defined Error.
helpfile
Unsupported.
helpcontext
Unsupported.

Return Value

None.

Remarks

All the parameters are optional except number. If you use Raise without specifying some parameters, and the property settings of the Err object contain values that have not been cleared, those values serve as the values for your error.

Raise is used for generating run-time errors and can be used instead of the Error statement. Raise is useful for generating errors when writing class modules, because the Err object gives more comprehensive information than is possible if you generate errors with the Error statement.