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 |
---|
|
Visual Basic for Applications |
---|
|
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 |
---|
|
Visual Basic for Applications |
---|
|
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. |
Note |
---|
For more information about the properties, methods, and events of the Form object, see Form Object Members. |
See Also
- Application Object
- Control Object
- Controls Collection
- Forms Collection
- How to: Apply a Custom Ribbon to a Form or Report
- How to: Apply a Filter When Opening a Form or Report
- How to: Bind a Form to an ADO Recordset
- How to: Cancel the Deletion of a Record by Using Custom Criteria
- How to: Change the Filter or Sort Order of a Form or Report
- How to: Create Multiple Instances of a Form
- How to: Determine Whether The Current Record is a New Record In a Form
- How to: Disable PAGE UP and PAGE DOWN Keys in a Form
- How to: Hide a Subform if the Main Form Contains No Records
- How to: Perform Simple Data Validation Checks When Editing a Record in a Form
- How to: Prevent the Accidental Erasure of Data When Moving Between Controls on a Form
- How to: Prompt a User Before Closing a Form
- How to: Prompt a User Before Saving a Record
- How to: Refer to Tab Control Objects in VBA
- How to: Set Form, Report, and Control Properties in Code
- How to: Specify Date and Time in Criteria Expressions
- How to: Suspend Code Execution Until a Pop-up Form is Closed
- How to: Synchronize a DAO Recordset's Record with a Form's Current Record
- How to: Synchronize Two Combo Boxes on a Form
- How to: Use Date and Time Criteria from a Control on a Form
- How to: Use Multiple Fields in Criteria Expressions
- How to: Use Numeric Criteria from a Control on a Form
- How to: Use Textual Criteria from a Control on a Form
- How to: Use User Input to Build Filter Criteria
- How to: Work with Form and Report Printer Settings