We are Access Experts. Call Us Today! 773-809-5456

Any Access version → How to refer to subforms in control sources

In our other tutorial, we saw how you can quickly, and easily refer to subforms within VBA code. Referring to subforms in control sources must take a slightly different tack. Subform syntax is actually fairly simple, but there are quite a few nuances to pick up on.

As a reminder as to the main concepts of subforms on main forms:

  1. The subform actually doesn’t exist as a form on the main form. It must live within a subform CONTAINER control, which does several things. First, it is the interface through which linking between the main form and the subform will take place. Second, it also will be able to handle the sizing dynamically of the subform. And third, the subform container control will let you swap out subforms as you desire.
  2. When wanting to use any of the controls, methods, or properties of the actual subform, you must use .Form. to tell Access you are referring to the form and not the subform container control.
  3. When using code to refer to the subform, you use the subform CONTAINER name, and not the subform name itself. The subform container CAN have the same name as the subform but it also may not match. So, you need to know the name of the container control and use that within your code.

Control Sources and Subforms:
In control sources, it gets a little different, but only slightly. If you are wanting to refer to a control on a subform here’s an easy way to get to it: