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



Quick Reference: Linux Commands
Reduce stress and speed up resolutions with the easiest command references right at your fingertips. You'll receive a PDF file covering Linux, packed with the most common commands you'll need and use daily.
Buy Now
500 Things Every Technology Professional Needs to Know
Did you know Microsoft's RegClean does not work with XP but you can use shareware to clean your registry? Did you know most wireless access points don't have encryption enabled by default? Did you know there are 500 tidbits of information contained in TechRepublic's 500 Things Every Technology Professional Needs to Know that will help you become a successful IT professional.
Buy Now

SmartPlanet

Click Here