Access 2000 Tutorial · FGCU Technology Skills Orientation
 
« Form Controls Subforms More Forms »

What Is A Subform?

A subform is a form that is placed in a parent form, called the main form. Subforms are particularly useful to display data from tables and queries that have one-to-many relationships. For example, in the sample below, data on the main form is drawn from an item information table while the subform contains all of the orders for that item. The item record is the "one" part of this one-to-many relationship while the orders are the "many" side of the relationship since many orders can be placed for the one item.

[Sample Subform]

The remainder of this page explains three methods for creating subforms and they assume that the data tables and/or queries have already been created.

Create a Form and Subform at Once

Use this method if neither form has already been created. A main form and subform can be created automatically using the form wizard if table relationships are set properly or if a query involving multiple tables is selected. For example, a relationship can be set between a table containing customer information and one listing customer orders so the orders for each customer are displayed together using a main form and subform. Follow these steps to create a subform within a form:

  1. Double-click Create form by using wizard on the database window.
  2. From the Tables/Queries drop-down menu, select the first table or query from which the main form will display its data. Select the fields that should appear on the form by highlighting the field names in the Available Fields list on the left and clicking the single arrow > button or click the double arrows >> to choose all of the fields.
    [Form Wizard]
  3. From the same window, select another table or query from the Tables/Queries drop-down menu and choose the fields that should appear on the form. Click Next to continue after all fields have been selected.
  4. Choose an arrangement for the forms by selecting form with subform(s) if the forms should appear on the same page or Linked forms if there are many controls on the main form and a subform will not fit. Click Next to proceed to the next page of options.
    [Form Wizard]
  5. Select a tabular or datasheet layout for the form and click Next.
    [Form Wizard]
  6. Select a style for the form and click Next.
    [Form Wizard]
  7. Enter the names for the main form and subform. Click Finish to create the forms.
    [Form Wizard]
  8. New records can be added to both tables or queries at once by using the new combination form.

Subform Wizard

If the main form or both forms already exist, the Subform Wizard can be used to combine the forms. Follow these steps to use the Subform Wizard:

  1. Open the main form in Design View and make sure the Control Wizard button [Control Wizard button] on the toolbox is pressed in.
  2. Click the Subform/Subreport icon [Subform icon] on the toolbox and draw the outline of the subform on the main form. The Subform Wizard dialog box will appear when the mouse button is released.
  3. If the subform has not been created yet, select "Use existing Tables and Queries". Otherwise, select the existing form that will become the subform. Click Next to continue.
    [SubForm Wizard]
  4. The next dialog window will display table relationships assumed by Access. Select one of these relationships or define your own and click Next.
    [SubForm Wizard]
  5. On the final dialog box, enter the name of the subform and click Finish.

Drag-and-Drop Method

Use this method to create subforms from two forms that already exist. Make sure that the table relationships have already been set before proceeding with these steps.

  1. Open the main form in Design View and select Window|Tile Vertically to display both the database window and the form side-by-side.
    [Drag-and-Drop example]
  2. Drag the form icon beside the name of the subform onto the detail section of the main form design.
    [Drag-and-Drop example]
« Form Controls Subforms More Forms »
 

Office 2000 Tutorials · Word · Excel · Power Point · Access · FrontPage

FGCU does not provide personal support for Office 2000 programs to outside parties.