ClearMacroError マクロ アクション
適用先: Access 2013、Office 2013
You can use the ClearMacroError action to clear information about an error that is stored in the MacroError object.
設定
"ClaerMacroError/マクロエラーのクリア" アクションには、引数はありません。
注釈
マクロでエラーが発生すると、エラーに関する情報が MacroError オブジェクトに格納されます。 OnError アクションを使用してエラー メッセージを抑制していない場合、マクロは停止し、エラー情報が標準エラー メッセージに表示されます。 ただし、 OnError アクションを使用してエラー メッセージを抑制した場合は、 MacroError オブジェクトに格納されている情報を条件またはカスタム エラー メッセージで使用できます。
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. Doing so resets the error number in the MacroError object to 0 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.
The MacroError object is automatically cleared when any macro ends, so you do not need to use the ClearMacroError action at the end of a macro.
MacroError オブジェクトには、一度に 1 つのエラー情報のみが格納されます。 マクロで複数のエラーが発生した場合は、最後のエラーに関する情報だけが MacroError オブジェクトに格納されます。
To run the ClearMacroError action in a VBA module, use the ClearMacroError method of the DoCmd object.
例
The following macro uses the OnError action with the Next argument to suppress error messages, and then uses the OpenForm action to open a form. For this example, an error is deliberately created by using the GoToRecord action to go to the previous record. The condition [MacroError].[Number]<>0 tests the MacroError object. If an error has occurred, the error number is non-zero, and the MessageBox action runs. The message box displays the name of the action that caused the error (in this case, the GoToRecord action), and the error number is displayed. Finally, running the ClearMacroError action clears the MacroError object.
条件 |
アクション |
引数 |
---|---|---|
OnError |
[移動]:[次へ] |
|
OpenForm |
フォーム名: CategoryFormView: FormWindow モード: Normal |
|
GoToRecord |
オブジェクトの種類: FormObject 名: CategoryFormレコード: 前 |
|
[MacroError]。[数値]<>0 |
MessageBox |
メッセージ: ="Error # " & [MacroError]。[数値] & " on " on " & [MacroError].[ActionName] & " action" です。ビープ音: YesType: 情報 |
ClearMacroError |