Save Macro Action

You can use the Save action to save either a specified Access object or the active object if none is specified. You can also save the active object with a new name in some cases (this functions the same as the Save As command on the Quick Access Toolbar).

** Note **  This action will not be allowed if the database is not trusted. For more information about enabling macros, see the links in the See Also section of this article.

Setting

The Save action has the following arguments.

Action argument Description
Object Type The type of object you want to save. Click Table, Query, Form, Report, Macro, Module, Data Access Page, Server View, Diagram, Stored Procedure, or Function in the Object Type box in the Action Arguments section of the Macro Builder pane. To select the active object, leave this argument blank. If you select an object type in this argument, you must select an existing object's name in the Object Name argument.
Object Name The name of the object to be saved. The Object Name box shows all objects in the database of the type selected by the Object Type argument. If you leave the Object Type argument blank, you can leave this argument blank to save the active object, or, in some cases, enter a new name in this argument to save the active object with this name.

If you enter a new name, the name must follow the standard naming conventions for Microsoft Office Access 2007 objects.

Remarks

The Save action works on all database objects that the user can explicitly open and save. The specified object must be open for the Save action to have any effect on the object. This action has the same effect as selecting an object and then saving it by clicking Save on the Quick Access Toolbar. Leaving the Object Type argument blank and entering a new name in the Object Name argument has the same effect as clicking Save As on the Quick Access Toolbar, and entering a new name for the active object. Using the Save action enables you to specify an object to save and to perform a Save As command from a macro.

** Note **  You can't use the Save action to save any of the following with a new name:

  • A form in Form view or Datasheet view.
  • A report in Print Preview.
  • A module.
  • A server view in Datasheet view or Print Preview.
  • A data access page in Page view.
  • A table in Datasheet view or Print Preview.
  • A query in Datasheet view or Print Preview.
  • A stored procedure in Datasheet view or Print Preview.

The Save action, whether it's carried out in a macro run in the current database or in a library database, always saves the specified object or the active object in the database in which the object was created.

If you save the active object with a new name, but the name is the same as the name of an existing object of this type, a dialog box asks if you want to overwrite the existing object. If you've set the Warnings On argument of the SetWarnings action to No, the dialog box isn't displayed and the old object is automatically overwritten.

To run the Save action in a Visual Basic for Applications (VBA) module, use the Save method of the DoCmd object.

See Also

  • Enable or disable macros in Office documents