Create a subform

Microsoft Office Access 2003

  1. In the Database window, click Forms Button image under Objects.
  2. Click the New button on the Database window toolbar.
  3. In the New Form dialog box, double-click Form Wizard.
  4. In the first wizard dialog box, select a table or query from the list. For example, to create a Categories form that displays products for each category in a subform, select the Categories table (the "one" side of the one-to-many relationship).

    Note  It doesn't matter which table or query you choose first.

  5. Double-click the fields you want to include from this table or query.
  6. In the same wizard dialog box, select another table or query from the list. Using the same example, select the Products table (the "many" side of the one-to-many relationship).
  7. Double-click the fields you want to include from this table or query.
  8. 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 Categories form, click By Categories.
  9. In the same wizard dialog box, select the Form With subform(s) option.
  10. Follow the directions in the remaining wizard dialog boxes. When you click Finish, Microsoft Access creates two forms, one for the main form and subform control, and one for the subform.

ShowCreate a subform and add it to another form

  1. Open the form that you want to add the subform to in Design view.
  2. Make sure the Control Wizards tool Button image in the toolbox is pressed in.
  3. Click the Subform/Subreport tool Button image in the toolbox.
  4. On the form, click where you want to place the subform.
  5. Follow the directions in the wizard dialog boxes.
  6. When you click Finish, Microsoft Access adds a subform control to your form. It also creates a separate form for the subform.

ShowAdd a form to another form to create a form with a subform

  1. Open the form that you want to use as the main form in Design view. This is usually a form based on a table or query on the "one" side of a one-to-many relationship.
  2. Make sure the Control Wizards tool Button image in the toolbox is pressed in.
  3. Press F11 to switch to the Database window.
  4. Drag a form, table, or query from the Database window to the main form.

ShowCreate a form with two subforms

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, and the main form contains both the subform controls.

  1. In the Database window, click Forms Button image under Objects.
  2. Click the New button on the Database window toolbar.
  3. In the New Form dialog box, double-click Form Wizard in the list.
  4. 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).

    Note  It doesn't matter which table or query you choose first.

  5. Double-click the fields you want to include from this table or query.
  6. 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.
  7. 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.
  8. 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.
  9. In the same wizard dialog box, select the Form With subform(s) option.
  10. 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 Button image next to the OnCurrent property.
  • The Customer Orders form in the Northwind sample database is a form with two subforms. To view this form, point to Sample Databases on the Help menu, click either Northwind Sample Database or Northwind Sample Access Project, and then open the Customer Orders form in Design view.

ShowCreate a form with nested subforms

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, and the second subform is embedded in the first subform.)

  1. Create a form with a subform.

    ShowHow?

    1. In the Database window, click Forms Button image under Objects.
    2. Click the New button on the Database window toolbar.
    3. In the New Form dialog box, double-click Form Wizard.
    4. In the first wizard dialog box, select a table or query from the list. For example, to create a Categories form that displays products for each category in a subform, select the Categories table (the "one" side of the one-to-many relationship).

      Note  It doesn't matter which table or query you choose first.

    5. Double-click the fields you want to include from this table or query.
    6. In the same wizard dialog box, select another table or query from the list. Using the same example, select the Products table (the "many" side of the one-to-many relationship).
    7. Double-click the fields you want to include from this table or query.
    8. 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 Categories form, click By Categories.
    9. In the same wizard dialog box, select the Form With subform(s) option.
    10. Follow the directions in the remaining wizard dialog boxes. When you click Finish, Microsoft Access creates two forms, one for the main form and subform control, and one for the subform.

    Note  Select the Tabular (the equivalent of Form view) option when the wizard asks what layout you want for the subform.

  2. In Design view of the main form, select the subform control and click again inside the control t o select the form, just as you would if you opened the subform in Design view from the Database window.
  3. Do one of the following:
    • Repeat step 1 to create the second subform by using the wizard.
    • Drag a form, table, or query from the Database window to the subform. Microsoft Access creates another subform inside the first subform and creates a form for the subform.