One-to-many
Forms
These are
sometimes called master-detail forms. The basic idea is that one table
is the parent or master table. The other is the child or detail. The
parent is the record source for a main form in which a subform is
embedded with the child table as the record source. There are several
ways to create one-to-many forms. First let's have a look at what one
looks like. It's
a simple example showing a work order with labor tickets applied.
The main form
uses the work_orders table as the record source. The subform uses the
labor table. There is a foreign key, wono, in the labor table
which refers to the primary key, wono, in the work_orders
table. Here is what the relationship look like.
We'll create
this the manual way. Once we know what is going on we'll look at how
to speed the process up with the Form Wizard.
There are
three basic steps.
-
Create the subform
-
Create the
main form
-
Add the
subform to the main form
1. Create
the subform
Use the Form Wizard to create a form just as for a simple data entry
form. But select a tabular or dataheet format. Remove extraneous
controls, labels, etc. Use the child table as the record source. When
done you should have something that looks like the one below (I did
mine in tabular format).
Save it. The convention for subform name prefixes is sfrm. Some
people use frmsub.
2. Create
the Main Form
Create the
main, or master, form using a columnar format and the parent table as
the record source.
3. Add the
Subform to the Main Form
Drag and drop
the subform on the the main form. Voila. You now have a master-detail form.
On the next
page we'll take a look at the property sheet.
Continue
to page 3 - one to many forms cont'd ... |