How to reference an Access subform
- Date: July 5th, 2007
- Author: Susan Harkins
- Category: Microsoft Access
- Tags: Microsoft Access, Control, Susan Harkins
Referencing subform controls always throws Access users for a loop while they’re new to using Visual Basic for Applications (VBA). That’s because Access views the subform as just another one of the form’s controls.
To refer to a form, identify the form via the Forms collection as follows:
Forms!formname
Reference specific controls and subforms via the form’s Controls collection:
Forms!formname!subformname
The subform is actually a control, but it’s a control with dependent controls. That means you must identify both levels: the subform and the subform’s controls. To do so, use the subform (control’s) Form property in the form:
Forms!formname!subformname.Form.controlname
If the object name contains spaces, you must enclose any instance in brackets:
Forms![form name]![control name].Form.[control name]
In addition, you can use the Me identifier when the form is current, as follows:
Me!subformname.Form.controlname
Print/View all Posts Comments on this blog
|
|
|
|
|
|

