Save Method
The Save method carries out the Save action in Visual Basic.
expression.Save(ObjectType, ObjectName)
expression Required. An expression that returns one of the objects in the Applies To list.
ObjectType Optional AcObjectType.
AcObjectType can be one of these AcObjectType constants. |
acDataAccessPage |
acDefault default |
acDiagram |
acForm |
acFunction |
acMacro |
acModule |
acQuery |
acReport |
acServerView |
acStoredProcedure |
acTable
Note If closing a module in the Visual Basic Editor (VBE), you must use acModule in the objecttype argument. |
ObjectName Optional Variant. A string expression that's the valid name of an object of the type selected by the objecttype argument.
Remarks
For more information on how the action and its arguments work, see the action topic.
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.
- A data
access page in Page view.
- 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.
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.
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"