DoCmd.Close (Access)
The Close method carries out the Close action in Visual Basic.
You can use the Close method to close either a specified Microsoft Access window or the active window if none is specified. If you leave the ObjectType and ObjectName arguments blank (the default constant, acDefault, is assumed for ObjectType), Access closes the active window. If you specify the Save argument and leave the ObjectType and ObjectName arguments blank, you must include the ObjectType and ObjectName arguments' commas.
Close (ObjectType, ObjectName, Save)
Private Sub cmdCloseForm_Click()
On Error GoTo Err_cmdCloseForm_Click
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close
Exit_cmdCloseForm_Click:
Exit Sub
Err_cmdCloseForm_Click:
MsgBox Err.Description
Resume Exit_cmdCloseForm_Click
End Sub
Arguments
Optional arguments
The following arguments are optional
ObjectType (AcObjectType) - An AcObjectType constant that represents the type of object to close.
Here you can find possible values for
ObjectName (String) - A string expression that's the valid name of an object of the type selected by the ObjectType argument.
Save (AcCloseSave) - An AcCloseSave constant that specifies whether to save changes to the object. The default value is acSavePrompt.
Possible return values are acSaveNo - The specified object is not saved, acSavePrompt - The user is asked whether or not they want to save the object. NOTE: This value is ignored if you are closing a Visual Basic module. The module will be closed, but changes to the module will not be saved, acSaveYes - The specified object is saved.