A Form object refers to a particular Microsoft Access form.
A Form object is a member of the Forms collection. Within the Forms collection, individual forms are numbered by an index beginning with zero. You can refer to an individual Form object in the Forms collection either by referring to the form by name, or by referring to its index within the collection. If the form name includes a space, the name must be surrounded by brackets.
Syntax |
Example |
Forms!formname |
Forms!OrderForm |
Forms![form name] |
Forms![Order Form] |
Forms("formname") |
Forms("OrderForm") |
Forms(index) |
Forms(0) |
Each Form object has a Controls collection, which contains all controls on the form. You can refer to a control on a form either by implicitly or explicitly referring to the Controls collection. Your code will be faster if you refer to the Controls collection implicitly. The following examples show two of the ways you might refer to a control named NewData on the form called OrderForm.
Forms!OrderForm!NewData ' Implicit reference.!OrderForm.Controls!NewData ' Explicit reference.
Many of the properties of a Form object can also be set from a form’s property sheet. For information on how to set individual properties, search the online index for those properties.
Control Object, Controls Collection, Forms Collection, Me.
See the Backcolor property example.