TechRepublic : A ZDNet Tech Community

Microsoft Office

Host: Susan Harkins
Contact

One of the most common mistakes I see, and hear about it, is improper syntax when referencing controls on a subform. As far as Access is concerned, a subform is just another control on the main form — and that’s what confuses folks.

First, let’s review referencing controls in general. Use either of the following syntax statements to reference a control on a main form:

Forms!formname!controlname
Me!controlname

(In more recent versions, you can substitute bang (!) with dot (.) between objects.)

To refer to a subform or a control on a subform, you must remember that Access treats the subform as a control. Essentially, you have a form with a control with a control. To express that arrangement in terms Access can decipher, you need the Form property as follows

Forms!mainform!subform.Form.controlonsubform
Me!subform.Form.controlonsubform

In other words, subform is simply a control on the main form.

What I commonly see is a simple transposition of the Form property and subform, which generates a runtime error:

Forms!mainform.Form.subform.controlonsubform

In this form, Access assumes Form is a control. When it can’t find a control named form, Access returns an error.

Print/View all Posts Comments on this blog

To counterphrase Little Red Riding Hood ... Marshwiggle | 07/31/08

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