A subform is a form within a form. Subforms are especially useful when you want to show data from tables or queries with a one—to—many relationship. For example, a Customer form might have a subform that displays each customer's Orders.
The main form and subform are linked so that the subform displays only records that are related to the current record in the main form. For example, when the main form displays a particular customer, the subform displays only orders for that customer.
- In Design View, resize the form as necessary.
Now you're ready to add the subform.
- Click the Controls button on the ribbon.
- Click the Subform/Subreport button.
The mouse pointer changes to a
, indicating that you can click and drag the subform onto the main form.
- Click and drag where you want the subform to appear.
The Subform Wizard appears and asks if you want to use an existing form for your subform or create a new one using tables or queries.
- Click the Next button.
The next step of the Wizard appears. Here you have to select the table or query and fields that you want to display in your subform.
- Click the Tables/Queries list arrow and select a table or query.
It's very important that the underlying tables or queries of the main form and subform have a related field and that the related field appears somewhere on both forms.
Now you need to select the fields you want to appear in the subform. You must select the related field used to join the main form and subform. This related field must appear on both the main form (where it is called the parent field) and on the subform (where it is called the child field).
- Select the fields you want to appear in the subform and click Next.