Form Object

Access Developer Reference

A Form object refers to a particular Microsoft Access form.

Remarks

A Form object is a member of the Forms collection, which is a collection of all currently open forms. Within the Forms collection, individual forms are indexed 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 you want to refer to a specific form in the Forms collection, it's better to refer to the form by name because a form's collection index may change. If the form name includes a space, the name must be surrounded by brackets ([ ]).

Syntax Example

AllForms!formname

AllForms!OrderForm

AllForms![form name]

AllForms![Order Form]

AllForms("formname")

AllForms("OrderForm")

AllForms(formname)

AllForms(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:

Visual Basic for Applications
  ' Implicit reference.
Forms!OrderForm!NewData
Visual Basic for Applications
  ' Explicit reference.
Forms!OrderForm.Controls!NewData

The next two examples show how you might refer to a control named NewData on a subform ctlSubForm contained in the form called OrderForm:

Visual Basic for Applications
  Forms!OrderForm.ctlSubForm.Form!Controls.NewData
Visual Basic for Applications
  Forms!OrderForm.ctlSubForm!NewData
image The following links were provided by Luke Chung. Luke is the founder and president of FMS, Inc., a leading provider of custom database solutions and developer tools.
Bb214211.vs_note(en-us,office.12).gif  Note
For more information about the properties, methods, and events of the Form object, see Form Object Members.

See Also