>
Source Property
Applies To
Error Object.
Description
Returns the name of the object or application that originally generated the error.
Return Values
The return value is a string expression representing the object or application that generated the error.
Remarks
The Source property specifies a string expression representing the object that originally generated the error; the expression is usually the object's class name or programmatic ID. Use the Source property to provide your users with information when your code is unable to handle an error generated in an accessed object. For example, if you access Microsoft Excel and it generates a Division by zero error, Microsoft Excel sets Error.Number to its error code for that error and sets the Source property to Excel.Application. Note that if the error is generated in another object called by Microsoft Excel, Microsoft Excel intercepts the error and sets Error.Number to its own code for Division by zero. However, it leaves the other Error object properties (including the Source property) as set by the object that generated the error. The Source property always contains the name of the object that originally generated the error — your code can try to handle the error according to the error documentation of the object you accessed. If your error handler fails, you can use the Error object information to describe the error to your user, using the Source property and the other Error properties to inform the user which object originally caused the error, its description of the error, and so forth.
Note
The On Error Resume Next construct may be preferable to On Error GoTo when dealing with errors generated during access to other objects. Checking the Error object property after each interaction with an object removes ambiguity about which object your code was accessing when the error occurred. Thus, you can be sure which object placed the error code in Error.Number, as well as which object originally generated the error (the one specified in Error.Source).
See Also
Description Property.
Specifics (Microsoft Access)
The data access Source property applies to the Error object and can be read only from Visual Basic.
Note
Don't confuse this property with the Microsoft Access Source property, which applies to a query and specifies the source connection string and source database for the query's input table or query.
Example
See the Decription property example.