Different ways to open an Access form using DoCmd.OpenForm

Builder Open Form

A form has many properties that determine its behaviour. These properties concern the way data are presented, possible filters, how it can be used to enter of edit data etcetera. When you design your form, that is the time you will decide on the defaults for your form. However you may want to use roughly the same form in different ways. A powerful way to change from the design-time default behaviour is using the DocDmd.OpenForm arguments.

OpenForm with FormName

The simple way to open a form is by supplying the FormName and keeping all the defaults.


DoCmd.OpenForm FormName:="Customer"

When opened this way Access interprets the command with defaults as here:


DoCmd.OpenForm FormName:="Customer", View:=acNormal, DataMode:=acFormPropertySettings, WindowMode:=acWindowNormal
menu Open Form View

OpenForm View

The most common ways to open a form are as Form (acNormal) or as datasheet (acFormDS). Special View modes which can only be set in design time are Split form and Continuous form. A split form can be useful if the user wants to easily navigate between records and at the same time make changes to the data. More info: Create a split form. A continuous form is used when a datasheet is insufficient.

Other view modes are acFormPivotTable and acFormPivotChart. For more info see Programming Pivot Tables for Access Forms

menu Open Form data mode

Data mode

If you leave the DataMode argument blank the default constant, acFormPropertySettings, is assumed. This opens the form in the data mode set by the form's AllowEdits, AllowDeletions, AllowAdditions and DataEntry properties.

The other possible DataMode values are:

  • acFormAdd - which opens the form on a 'new' (empty) record allowing the user to create a new record.
  • acFormEdit - shows the contect of the current selected record and allows editing.
  • acFormReadOnly- no adding or editing allowed.
menu Open Form WindowMode

OpenForm WindowMode

The default value acWindowNormal shows the form as normally done in Access. Using acDialog causes the form's Modal and PopUp properties to be set to Yes. With acDialog your calling code should not continue until the form is closed.

OpenForm using FilterName

FilterName refers to a query in the current database. You can use either an existing query or a filter that was saved as a query. You can use it both for getting a subset and for having it sorted.

OpenForm Where Condition

A valid SQL WHERE clause (without the word WHERE) to select records from the form's underlying table or query. If you select a filter with the Filter Name argument, Access applies this WHERE clause to the results of the filter.

To open a form and restrict its records to those specified by the value of a control on another form, use the following expression:

[fieldname] = Forms![formname]![controlname on other form]

Replace fieldname with the name of a field in the underlying table or query of the form you want to open. Replace formname and controlname on other form with the name of the other form and the control on the other form that contains the value you want records in the first form to match.

OpenForm OpenArgs

OpenArgs gives an opportunity to pass data to the form which it then can pick up in the Form_Open event. Example of how to do that can be found here.