You can use the CloseWindow action to close a specified Access document tab. If you don't specify a tab, it closes the active document tab.
Note
The CloseWindow macro action isn't available in Access web apps.
Settings
The CloseWindow macro action has the following arguments.
| Action argument | Description |
|---|---|
Object Type |
The type of object whose document tab you want to close. In the Object Type box in the Action Arguments section of the macro design window, select Table, Query, Form, Report, Macro, Module, Data Access Page, Server View, Diagram, Stored Procedure, or Function. To select the active document tab, leave this argument blank. If you're closing a module in the Visual Basic Editor, use Module for the Object Type argument. |
Object Name |
The name of the object to close. The Object Name box shows all objects in the database for the type selected in the Object Type argument. Select the object to close. If you leave the Object Type argument blank, leave this argument blank too. |
Save |
Determines whether Access saves changes to the object when it closes the object. Select Yes to save the object, No to close it without saving, or Prompt to prompt the user to save the object. The default is Prompt. |
Remarks
The CloseWindow action works on all database objects that the user can open or close directly. It has the same effect as selecting an object and closing it from its document tab. You can right-click the object's document tab and select Close on the shortcut menu, or select the Close button
for the object.
If the Save argument is set to Prompt and the object hasn't already been saved before the Close action runs, Access prompts the user to save the object before the macro closes it. If you set the Warnings On argument of the SetWarnings action to No, Access doesn't display the dialog box and saves the object automatically.
To run the CloseWindow action in a Visual Basic for Applications (VBA) module, use the Close method of the DoCmd object.