Save Method

Applies To

DoCmd object.

Description

The Save method carries out the Save action in Visual Basic. For more information on how the action and its arguments work, see the action topic.

Syntax

DoCmd.Save [objecttype, objectname]

The Save method has the following arguments.

Argument

Description

objecttype

One of the following intrinsic constants:

acDefault (default)
acForm
acMacro
acModule
acQuery
acReport
acTable

objectname

A string expression that's the valid name of an object of the type selected by the objecttype argument.


Remarks

If you leave the objecttype and objectname arguments blank (the default constant, acDefault, is assumed for the objecttype argument), Microsoft Access saves the active object. If you leave the objecttype argument blank, but enter a name in the objectname argument, Microsoft Access saves the active object with the specified name. If you enter an object type in the objecttype argument, you must enter an existing object's name in the objectname argument.

If you leave the objecttype argument blank, but enter a name in the objectname argument, you must include the objecttype argument's comma.

Note You can't use the Save method 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.
The Save method, whether it's 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.

See Also

Close method, CopyObject method, Quit method (Application object), Quit method (DoCmd object), Rename method, Save action, TransferDatabase method.

Example

The following example uses the Save method to save the form named "New Employees Form". This form must be open when the code containing this method runs.

DoCmd.Save acForm, "New Employees Form"