You can temporarily disable the modal (modal: A window or dialog box that requires the user to take some action before the focus can switch to another form or dialog box. Dialog boxes and messages are usually modal.) warning messages displayed by Microsoft Access while a macro or Microsoft Visual Basic procedure is running, and enable them again by carrying out the SetWarnings action in the macro or procedure.
Use a macro
- To open an existing macro, click Macros under Objects, select the macro, and then click the Design button on the Database window toolbar.
- In the place in the macro where you want to stop or resume the display of modal warning messages, add the SetWarnings action.
- In the Macro window, click the first empty row in the Action column. If you want to insert an action between two action rows, click the selector for the action row just below the row where you want to insert the new action, and then click Insert Row on the toolbar.
- In the Action column, click the arrow to display the action list.
- Click the action you want to use.
- In the lower part of the window, specify arguments for the action, if any are required. For action arguments whose settings are a database object name, you can set the argument by dragging the object from the Database window to the action's Object Name argument box.
- Type a comment for the action. Comments are optional.
- To temporarily stop the display of warning messages, set the Warnings On argument to No. To resume displaying them, set the Warnings On argument to Yes.
- Click Save to save the macro.
- To test, click Run on the toolbar.
If the Warnings On argument was set to No, the display of warning messages automatically resumes when the macro stops running.
Use Visual Basic code
- Open a Function or Sub procedure in the Code window.
- In the place in the procedure where you want to stop or resume the display of modal warning messages, use the SetWarnings method to carry out the SetWarnings action.
Microsoft Access defines a special object, DoCmd, that you use to carry out macro actions in Microsoft Visual Basic procedures. You carry out an action by adding a method of the DoCmd object to your procedure.
- In the procedure, add the DoCmd method that corresponds to the action by using the following syntax:
Method is the name of a method. Arguments are the method arguments, if there are any.
- To temporarily stop the display of warning messages, set the warningson argument to False. To resume displaying them, set the warningson argument to True.
- To test, run the procedure by opening the form in Form view and performing the event that triggers the procedure
If the the warningson argument was set to False, the display of warning messages automatically resumes when the code stops running.