<%dim crumb crumb="DoCmd Close" crumb1="DoCmd Close Form DoCmd Close Report" %> Docmd Close Example Microsoft Access
Home  Fees/Services  Access Templates  Tutorials  Access Download  Articles  Search  Forums  Blockchain Tech  Contact  Privacy  Links

DoCmd Examples - Access VBA<%response.write "
" & crumb1 %>

Docmd Macro VBA Example
Developer Home > Access Database Tutorials > DoCmd Examples<% response.write " > " & crumb %>
<% dim Gnum,Ynum Gnum="3847865006" Ynum="7164" dim Page_Type Page_Type="Prog" %>

DoCmd AddMenu
DoCmd ApplyFilter
DoCmd CancelEvent
DoCmd Close
DoCmd CopyObject
DoCmd DeleteObject
DoCmd FindRecord
DoCmd FindNext
DoCmd GotoControl
DoCmd HourGlass
DoCmd Min/Max/Restore
DoCmd OpenForm
DoCmd OpenQuery
DoCmd OpenReport
DoCmd OutputTo
DoCmd RunSQL
DoCmd SendObject
DoCmd TransferDatabase
DoCmd TransferText

Create Export Specs


Microsoft Office:
  MS Access 2003
  Access 2007
  Access 2010
  Access 2013

MS Access Docmd.Close Example

The Access Close method carries out the Close action in Visual Basic

Below are the syntax and command options for the Close method:

Microsoft Access Methods
(method syntax continued on next line)
Access database actions

ObjectType Optional AcObjectType.

AcObjectType can be one of these AcObjectType constants:
acDefault default
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.

Save Optional AcCloseSave.

AcCloseSave can be one of these AcCloseSave constants.

  • acSaveNo

  • acSavePrompt - default 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 - If you leave this argument blank, the default constant (acSavePrompt) is assumed.

If you leave the objecttype and objectname arguments blank (the default constant, acDefault, is assumed for objecttype), Microsoft 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.

Note If a form has a control bound to a field that has its Required property set to 'Yes,' and the form is closed using the Close method without entering any data for that field, an error message is not displayed. Any changes made to the record will be aborted. When the form is closed using the Windows Close button, the Close action in a macro, or selecting Close from the File menu, Microsoft Access displays an alert. The following code will display an error message when attempting to close a form with a Null field, using the Close method.

The following sample code uses the Docmd.Close method to close the form Order Review, saving any changes to the form without prompting:

DoCmd.Close acForm, "F_Orders", acSaveYes

More DoCmd.Close Examples:

NotInList Event in Microsoft Access

Microsoft Office:
MS Access 2003
Access 2007
Access 2010
Access 2013

Contact Information

<% Response.write "Copyright 2000-" & year(now) & " Blue Claw Database Design" %>