DoCmd.Close (ObjectType, ObjectName, Save)
- ObjectType: The type of object you intend to close.
- ObjectName: The name of an object that selected by ObjectType argument. It must be written between double quotes.
-Save: An constant that specifies to save changes the object or not. There are three types of Save argument:
+ acSaveNo: When you select this option, the saving changes to the object is not performed.
+ acSavePrompt: When you close the object, one message alerts to ask you to save or don't save the changing of the object. It is the default value of Save argument.
+ acSaveYes: The changing of the object is saved automatically without prompting.
The arguments of DoCmd.Close method can be blank. If you leave ObjecfType and ObjectName arguemnts blank, Microsoft Access closes the active window. If you set Save argument and leave the ObjectType and ObjectName argument blank, the comma of ObjectType and ObjectName argument must be included.
For example, you intend to close the form BookSearch when you click Close button on this form. The prompting any changes to the form is performed when the form is closed. To solve the example, you need to apply the VBA code in CmdClose's click event procedure as the following:
Private Sub CmdClose_Click()
Note: The name of Command Button is optional.
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages: