A FORM WITH A SUB-FORM
One way to display information form a number of related tables is
to define a sub-form within a containing (or parent) form. By linking
the two forms, only related rows are displayed.
Firstly, create a new form based on the ALBUMS table similar to that
displayed.
Notice that the form has a HEADER and a FOOTER created from the FORMAT
menu off the TOP MENU. Notice that the labels for all fields have
been deleted except for AlbName and Artist which have been modified.
Leave space at the bottom of the form detail for the embedded (child)
form. Save this form as Album Details into your database container.
- Create a NEW FORM, nominate the table TRACKS as the basis of the
form, then choose the FORM WIZARD.
- Select a Tabular Form then Ok. From the list of available fields
for the form, add [>] SONG then Next.
- Select the Standard style of form then Finish and you get a FORM
VIEW similar to that pictured.
Form wizards assume you want a standard format, and add detail that
might be needed or might not - typically you will need to customise
automatically generated forms and this is the case here.
Go into DESIGN VIEW and edit the form by removing the header and
footer (you want this form to be a component of another form, not
an apparently independent data display area), shrink the total form
to be the width of 1 field, centre the text (press the centre alignment
button on the button bar) so it resembles that pictured right. SAVE
this form as Track Listing
Re-open the DESIGN VIEW of the Album Details form. Select the SUBFORM/SUBREPORT
button on the TOOLS menu. Click and drag an area in the blank space
on your form to create an UNBOUND SUBFORM (this means it does not
yet relate to any existing database object). Open up the PROPERTIES
sheet for the unbound subform area. Select the SOURCE OBJECT to be
the TRACKLISTING form. To join the subform to the parent form, indicate
Link Child Fields: SerNum and Link Master Fields : SerNum (this is
the join condition)
Try your composite form out by switching to FORM VIEW.
As can be seen, the controls on the subform could be confusing. By
altering the properties of the subform (TRACKLISTING), it is possible
to control the appearance of the subform: Vertical Only scroll bars,
no record selectors, no navigation buttons, no control box, no max
or min button; results in the finished form pictured below.