TechRepublic : A ZDNet Tech Community

Microsoft Office

Host: Susan Harkins
Contact

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

Subforms of Subforms peter.weir@... | 07/05/07
MVP Sample Database ssharkins@... | 07/06/07
RE: How to reference an Access subform edward.talerico@... | 08/08/07

What do you think?

White Papers, Webcasts, and Downloads

Recent Entries

TR on Twitter

Archives

TechRepublic Blogs



IT Professional's Guide to Policies and Procedures, Third Ed
Whether you're creating policies for management, training, personnel, support, privacy, Internet/e-mail usage, security, or inventory, you'll meet the needs of your entire enterprise with this one download!
Buy Now
IT Help Desk Survival Guide, Third Edition
TechRepublic's IT Help Desk Survival Guide, Third Edition provides tools and recommendations to help you better manage help desk services, improve end-user support, troubleshoot frustrating hardware issues, identify quick fixes to vexing Windows problems, and help users make the most of Microsoft Office 2003.
Buy Now

SmartPlanet

Click Here