Now that you have trapped an error, what do you do with it? The answer depends on the nature of your application and the nature of the error.
VB and VBA provide information on the type of error that has been trapped by using the Err object. This object has several properties: Number, Description, Source, HelpFile, HelpContext, and LastDLLError. The properties of the Err object get filled in with the information for the most current error. The most important properties are the Number and Description properties. The Number property contains the unique error code associated with the error, and the Description property contains the error message that would normally be displayed.
In your error handler you can compare the Number property of the error to an expected value. This will help you determine the nature of the error that has occurred. Once you know what kind of error you are dealing with, you can take the appropriate action.