Microsoft Office Tutorials and References
In Depth Information
Opening Forms with DoCmd
FilterName specifies the name of a query within the current database,
which limits records displayed by the form. If this variable is omitted, no
query filter is applied.
WhereCondition represents an expression, enclosed in quotation marks,
that specifies records to include. If this variable is omitted, all records
are available. Entering a WhereCondition such as “[State] = ‘CA’”
displays only records that have CA in the State field.
DataMode specifies the data entry mode in which the form opens, using
one of the following constants:
• acFormatPropertySettings: Opens the form in its default
view, as specified in the form’s AllowEdits, AllowDeletions,
AllowAdditions, and DataEntry properties. If you don’t specify a
DataMode argument in the statement, this setting is used by default.
• acFormAdd: Opens the form with the capability to add new records
enabled and the cursor in a new, empty record.
• acFormEdit: Opens the form with the capability to edit records
contained within the table.
• acFormReadOnly: Opens the form in read-only mode so that the
user can only view — not change — the data.
WindowMode specifies the appearance of the form window upon opening,
using any of the following options:
• acWindowNormal: Opens the form in its normal view. If you omit this
argument, acWindowNormal is the setting that’s applied automatically.
• acDialog: Opens the form by using a fixed-size, dialog-box-style
• acHidden: Opens the form so that the code can have access to the
form’s controls and data but doesn’t make the form visible onscreen.
• acIcon: Opens the form minimized to an icon in the Access program
OpenArgs can be used to pass data to the form’s class module, where
other code can use it.
When you type a DoCmd.OpenForm statement in the Code window, the
Quick Info syntax chart keeps you posted on which argument you’re
currently typing (by showing that argument in boldface). When you get to an
argument that requires a constant, the Code window displays a drop-down
menu of acceptable constants. You can just double-click, rather than type,
the constant that you want to use.
Look at some examples of using the OpenForm method of the DoCmd object.
The following line opens a form named Products Form:
DoCmd.OpenForm “Products Form”
Search JabSto ::

Custom Search