Create a form with two subforms
Before using this procedure, make sure you've set up your table relationships correctly.
You can use this procedure to create a form and two subforms that have a one-to-many-to-many relationship. The main form has a one-to-many relationship with the first subform, and the first subform has a one-to-many relationship with the second subform.
- In the Database window, click Forms under Objects.
- Click the New button on the Database window toolbar.
- In the New Form dialog box, double-click Form Wizard in the list.
- In the first wizard dialog box, select the table or query for the main form. For example, suppose you want to create a Customers form that has two subforms — an Orders subform and an Order Details subform. Select the Customers table (the "one" side of the first one-to-many relationship).
- Double-click the fields you want to include from this table or query.
- In the same wizard dialog box, select the table or query for the first subform. Using the same example, select the Orders table (the "many" side of the first one-to-many relationship), and then double-click the fields you want to include from this table or query.
Note It doesn't matter which table or query you choose first.
- In the same wizard dialog box, select the table or query for the second subform. Using the same example, select the Order Details table (the "many" side of the second one-to-many relationship), and then double-click the fields you want to include from this table or query.
- When you click Next, if you set up the relationships correctly before starting the wizard, the wizard asks which table or query you want to view by. Using the same example, to create the Customers form, click By Customers.
- In the same wizard dialog box, select the Form With Subform(s) option.
- Follow the directions in the remaining wizard dialog boxes. When you click Finish, Microsoft Access creates a main form with two subform controls. It also creates two other forms, one for each subform.
Notes
- When you use a wizard to create a form with two subforms, Microsoft Access synchronizes the subforms by attaching an event procedure to the OnCurrent property of the first subform. You can copy and modify this event procedure if you want to synchronize more subforms on the same form. To see this event procedure, open the first subform in Design view, double-click the form selector, and then click the Build button next to the OnCurrent property.
- The Customer Orders form in the Northwind sample database is a form with two subforms. To view this form, open the Northwind database in your Office folder's Samples folder, and then open the Customer Orders form in Design view. For information on opening Northwind, click .
- For information on changing the layout of a subform that the wizard creates, click .
- For information on troubleshooting subforms, click .