Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Referring to a control on a subform

From Wiki

Jump to: navigation, search

Finding the right names

What makes this very confusing is that you refer to the name of the main form, but after that, you must refer to subform controls and never mention the name of a form again. Forms are objects contained by subform controls, so it does not matter what your form is called in the database window, once it is used in a subform control, it just becomes an object, so it is very easy indeed to get the names wrong.


Is easy enough, but what comes next? Here are some notes on getting what comes next right.

Using the Immediate Window

To ensure you have the correct objects and names, open the form and click an item in the listbox, choose ctrl+G to open the immediate window (it will be part of a code window and have focus), paste the lines starting with a question mark into the immediate window.

This is the name of the control:


This is the name of the subform control that holds the form that the control is on:


This is the name of the form that holds the subform control:


If you have a tab control, it is not relevant.

You now have enough information to refer to the subform and control:

   Forms! + result from screen.ActiveControl.Parent.Parent.Name
          + .Form!
          + result from screen.ActiveControl.Parent.Name
          + !
          + result from screen.ActiveControl.Name



If you have spaces or special characters, you will need square brackets:


You may run into problems referring to nested subforms in code, in which case assign a subform to a form object, for example:

   Set frm = Me.[ASubformControl].Form.[ANestedSubformControl].Form


Using the Query Design Window

With MS Access 2010 and up, you can also use the query design window to get the names of your controls, but you need to have a reasonable idea of what they are before you start. Open the form so you have a reference, and open a query design window. Add any field to the grid and then go to the criteria line and type


You will see a list of forms, choose your form and type exclamation mark (!) to get a list of controls, choose the subform control and type stop followed by Form:


To get the form property, exclamation mark again will get you a list of subform controls, and so you build up the reference.


Refer also to: http://access.mvps.org/access/forms/frm0031.htm

841 Rating: 2.9/5 (37 votes cast)