3 - Subform From A Query:
The primary purpose of a subform is to display children data of a
parent form. It allows you to show data related to the main source. We
have already created subform in the past. This time, we would like the
form a little friendlier and better looking. To get that, we will create a
subform from a query that is itself created from a table.
1.
Open the Music Collection5 database.
2.
From the main menu, click Insert -> Query.
3.
From the New Query dialog, double-click Design View.
4.
From the Show Table dialog, double-click tblTracks and click Close.
5.
Click AlbumID, hold the Shift key, and click TrackLength. That will
select four fields.
6.
Drag the selected group to the first column of the lower portion of
the design grid.
7.
Save the query as qryTracks. Then close it.
8.
On the Standard toolbar, click the New Object arrow and choose
Form.
9.
In the New Form dialog, choose Form Wizard and choose qryTracks in
the lower combo box. Then click OK.
10.
Make sure the qryTracks is selected as the source of data. Select
all fields and click Next. Choose the Tabular layout, the Standard style
and click Next. Name the form sbfTracks, click the Modify the Form's
Design radio button, and click Finish.
11.
Right-click the Album Title's label and choose Properties. Click
the All tab and set the Visible field to No.
12.
Click the AlbumID text box and set its Visible field to No.
13.
Decrease the widths of both the Album label and the AlbumID text
box to 1/16 (or less, they are not going to be seen).
14.
Click the button at the intersection of both rulers to access the
form's properties. In the All tab, set the Navigation Buttons field to No.
15.
Save the subform.
16.
Open the frmAlbums form in Design View.
17.
On the Toolbox, make sure that the Control Wizard is pressed. Then
click the Subform/Subreport button. Click somewhere in the lower portion
of the form.
18.
On the Subform Wizard page, choose sbfTracks1 and click Next. Click
Next again, and click Finish.
19.
Resize the subform to fit proportionately in the form.
20.
Save and close the frmAlbums form.
|