Creating Multi-Table Forms

Forms can be created from more than one table using the Form Wizard or the Form Design view. Creating a form from fields that reside in more than one table allows you to enter data into more than one table using just the single form.

A very simple way to create a multi-table form is to add a subform to an existing form. For example, you might have a form that is based on a Customers table. If you would also like to be able to view and enter order information when you work with the Customers form, you can add an Orders subform to it. It is important that the tables used to create the two forms (the main form and the subform) are related tables.

graphics/term_icon.gif

Subform A form control that actually consists of an entire form based on another table or tables.


The easiest way to create a subform is to actually drag an existing form onto another form in the Design view. The following steps describe how you do it:

  1. Use the AutoForm feature, the Form Wizard, or the Form Design view to create two forms: the form that serves as the main form and the form that serves as the subform. These forms should be based on tables that are related (see Lessons 10 and 11 for more about creating forms).

  2. In the Form Design view, open the form that will serve as the main form.

  3. Size the Form Design window so that you can also see the database window in the Access workspace (see Figure 19.6).

    Figure 19.6. The subform is dragged from the database window onto the Design view of the main form.

    graphics/91fig06.jpg

  4. In the database window, be sure that the Forms list is showing. Then, drag the form that will serve as the subform onto the main form that is open in the Design view. When the mouse pointer enters the Design view, it becomes a control pointer. Release the mouse button when you are in the general area where you want to place the subform. The subform control appears on the main form.

  5. Maximize the Form Design window. Reposition or size the subform in the Design view until you are happy with its location (see Figure 19.7).

    Figure 19.7. The subform becomes another control on the main form.

    graphics/91fig07.jpg

  6. Save the changes that you have made to the main form ( specifically , the addition of the subform).

  7. To change to the Form view to view or add data to the composite form, click the View button on the Form Design toolbar.

Figure 19.8 shows the main form and the subform in the Form view. The form can be used to view or enter data into two tables at once.

Figure 19.8. The composite form can be used to view and enter data into more than one table.

graphics/91fig08.jpg



Microsoft Office 2003 All-in-One
Microsoft Office 2003 All-in-One
ISBN: B005HKSHB2
EAN: N/A
Year: 2002
Pages: 660
Authors: Joe Habraken

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net