Compartir a través de


DoCmd.Save Method (Access)

The Save method carries out the Save action in Visual Basic.

Syntax

expression .Save(ObjectType, ObjectName)

expression A variable that represents a DoCmd object.

Parameters

Name

Required/Optional

Data Type

Description

ObjectType

Optional

AcObjectType

A AcObjectType constant that specifies the type of object you want to save.

ObjectName

Optional

Variant

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

Remarks

The Save method works on all database objects that the user can explicitly open and save. The specified object must be open for the Save method to have any effect on the object.

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.

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.

  • A server view in Datasheet view or Print Preview.

  • 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.

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"

See Also

Concepts

DoCmd Object Members

DoCmd Object