OpenForm Method
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
The OpenForm method carries out the action in Visual Basic. For more information on how the action and its arguments work, see the action topic.
Syntax
DoCmd.OpenFormformname[, view][, filtername][, wherecondition][, datamode][, windowmode][, openargs]
The OpenForm method has the following arguments.
Argument | Description |
---|---|
formname | A string expression that's the valid name of a form in the current database. |
If you execute Visual Basic code containing the OpenForm method in a library database, Microsoft Access looks for the form with this name first in the library database, then in the current database. | |
view | One of the following intrinsic constants: |
acDesign acFormDS acNormal (default) acPreview |
|
acNormal opens the form in Form view. | |
If you leave this argument blank, the default constant (acNormal) is assumed. | |
filtername | A string expression that's the valid name of a query in the current database. |
wherecondition | A string expression that's a valid SQL WHERE clause without the word WHERE. |
datamode | One of the following intrinsic constants: |
acFormAdd acFormEdit acFormPropertySettings (default) acFormReadOnly |
|
If you leave this argument blank (the default constant, acFormPropertySettings, is assumed), Microsoft Access opens the form in the data mode set by the form's , , , and properties. | |
windowmode | One of the following intrinsic constants: |
acDialog acHidden acIcon acWindowNormal (default) |
|
If you leave this argument blank, the default constant (acWindowNormal) is assumed. |
|
openargs | A string expression. This expression is used to set the form's property. This setting can then be used by code in a form module, such as the Open event procedure. The OpenArgs property can also be referred to in macros and expressions. |
For example, suppose that the form you open is a continuous-form list of clients. If you want the focus to move to a specific client record when the form opens, you can specify the client name with the openargs argument, and then use the FindRecord method to move the focus to the record for the client with the specified name. | |
This argument is available only in Visual Basic. |
Remarks
The maximum length of the wherecondition argument is 32,768 characters (unlike the Where Condition action argument in the Macro window, whose maximum length is 256 characters).
You can leave an optional argument blank in the middle of the syntax, but you must include the argument's comma. If you leave a trailing argument blank, don't use a comma following the last argument you specify.