Class MacroError (Access VBA)
The class MacroError represents the properties of a run-time error that occurs in a macro. To use a MacroError class variable it first needs to be instantiated, for example
ActionName
Gets the name of the macro action that was executing when an error occurred.
When an error occurs in a macro, information about the error is stored in the MacroError object. If you have not used the OnError action to suppress error messages, the macro stops and the error information is displayed in a standard error message. However, if you have used the OnError action to suppress error messages, you may want to use the information stored in the MacroError object in a condition or a custom error message. After an error has been handled, the information in the MacroError object is out of date, so it is a good idea to clear the object by using the ClearMacroError action. This resets the error number in the MacroError object back to zero, and clears any other information about the error that is stored in the object, such as the error description, macro name, action name, condition, and arguments. This way, you can inspect the MacroError object again later to see if another error has occurred.
MacroError.ActionName
Arguments
Gets the arguments specified for the macro action that was executing when an error occurred.
When an error occurs in a macro, information about the error is stored in the MacroError object. If you have not used the OnError action to suppress error messages, the macro stops and the error information is displayed in a standard error message. However, if you have used the OnError action to suppress error messages, you may want to use the information stored in the MacroError object in a condition or a custom error message. After an error has been handled, the information in the MacroError object is out of date, so it is a good idea to clear the object by using the ClearMacroError action. This resets the error number in the MacroError object back to zero, and clears any other information about the error that is stored in the object, such as the error description, macro name, action name, condition, and arguments. This way, you can inspect the MacroError object again later to see if another error has occurred.
MacroError.Arguments
Condition
Gets the condition of the macro action that was executing when an error occurred.
When an error occurs in a macro, information about the error is stored in the MacroError object. If you have not used the OnError action to suppress error messages, the macro stops and the error information is displayed in a standard error message. However, if you have used the OnError action to suppress error messages, you may want to use the information stored in the MacroError object in a condition or a custom error message. After an error has been handled, the information in the MacroError object is out of date, so it is a good idea to clear the object by using the ClearMacroError action. This resets the error number in the MacroError object back to zero, and clears any other information about the error that is stored in the object, such as the error description, macro name, action name, condition, and arguments. This way, you can inspect the MacroError object again later to see if another error has occurred.
MacroError.Condition
Description
Gets the text that represents the current error message.
When an error occurs in a macro, information about the error is stored in the MacroError object. If you have not used the OnError action to suppress error messages, the macro stops and the error information is displayed in a standard error message. However, if you have used the OnError action to suppress error messages, you may want to use the information stored in the MacroError object in a condition or a custom error message. After an error has been handled, the information in the MacroError object is out of date, so it is a good idea to clear the object by using the ClearMacroError action. This resets the error number in the MacroError object back to zero, and clears any other information about the error that is stored in the object, such as the error description, macro name, action name, condition, and arguments. This way, you can inspect the MacroError object again later to see if another error has occurred.
MacroError.Description
MacroName
Gets the name of the macro that was running when an error occurred.
When an error occurs in a macro, information about the error is stored in the MacroError object. If you have not used the OnError action to suppress error messages, the macro stops and the error information is displayed in a standard error message. However, if you have used the OnError action to suppress error messages, you may want to use the information stored in the MacroError object in a condition or a custom error message. After an error has been handled, the information in the MacroError object is out of date, so it is a good idea to clear the object by using the ClearMacroError action. This resets the error number in the MacroError object back to zero, and clears any other information about the error that is stored in the object, such as the error description, macro name, action name, condition, and arguments. This way, you can inspect the MacroError object again later to see if another error has occurred.
MacroError.MacroName
Number
Gets the current error number.
When an error occurs in a macro, information about the error is stored in the MacroError object. If you have not used the OnError action to suppress error messages, the macro stops and the error information is displayed in a standard error message. However, if you have used the OnError action to suppress error messages, you may want to use the information stored in the MacroError object in a condition or a custom error message. After an error has been handled, the information in the MacroError object is out of date, so it is a good idea to clear the object by using the ClearMacroError action. This resets the error number in the MacroError object back to zero, and clears any other information about the error that is stored in the object, such as the error description, macro name, action name, condition, and arguments. This way, you can inspect the MacroError object again later to see if another error has occurred.
MacroError.Number