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 | An AcObjectType constant that specifies the type of object that 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, 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"
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.