Access Controls  «Prev  Next»
Lesson 4Using the Subform control
ObjectiveCreate a Subform control to display data from a related table.

Using the Subform Control

Combo Box and List Box controls allow you to display information from another record source while on a form, as well as letting you update a lookup field in the form's record source. This is fine when you have only one field to update or want to view a little extra information. When you have to perform full editing capabilities with another related table while on a form, then the Subform control
, located in the toolbox, is the control to use.

A good example of using a Subform control would be to include the hours for each of the projects stored in the project database, Consulting307.mdb. You can see this example in the following figure:
Project Sub
Project Sub

As you move through each of the records in the Project table, the corresponding records in the Hours table will follow. Because the Subform control uses a form in its Control Object property, you can set the form to be one of the three standard views: Datasheet, Continuous, and Single. All the other features that you can take advantage of in standard forms apply to subforms, such as scroll bars and editing properties. Some things do not apply, such as the Caption or Border Style properties.
On the Subform control itself, three main properties need to be set:
  1. Source Object: This will be the form used as a subform.
  2. Link Child Fields: This will be the field or fields, located on the subform, used to link the subform with the main form.
  3. Link Master Fields: This will be the field or fields, located on the main form, used to link the main form to the subform.
When you use the Subform Wizard, the properties just discussed will be set for you when you answer the questions presented by the wizard.
Note that you can also have a subform within a subform, up to three levels deep.
In the next lesson, you will learn how to create a simple multipage form by using Access’s Tab control.