A subform (or a subreport) is a form that placed in the
body of an existing form (or report). The subform (or subreport) is usually
made to show some records. The records of the subform (or subreport) must
come from a table, a SQL expression, or a query.

Practical
Learning: Introducing Subforms

Start Microsoft Access

In the File Name text box, replace the name with College
Park Auto Repair3

Click Create

On the default table, double-click ID

Type RepairOrderID and press Enter

Right-click the Table1 and click Design View

Set the name of the table to RepairOrders

Click OK

Complete the table with the following fields:

Field Name

Data Type

Field Size

Format

Caption

Default Value

RepairOrderID

Repair Order ID

CustomerName

50

Customer Name

Address

60

City

40

State

40

ZIPCode

20

ZIP Code

Make

50

Model

50

CarYear

Number

Integer

Year

ProblemDescription

Memo

Problem Description

TaxRate

Number

Double

Percent

Tax Rate

0.0575

Recommendations

Memo

Save and close the table

On the Ribbon, click Create

To create a new table, in the Tables section, click Table

Double-click ID

Type PartUsedID and press Enter

Right-click the Table1 and click Design View

Set the name of the table to PartsUsed

Click OK

Complete the table with the following fields:

Field Name

Data Type

Field Size

Format

Caption

PartUsedID

Part Used ID

RepairOrderID

Number

Long Integer

RepairOrderID

PartName

50

Part Name

UnitPrice

Number

Double

Currency

Unit Price

Quantity

Number

Byte

Save and close the table

On the Ribbon, click Create

In the Tables section, click Table

Double-click ID

Type JobPerformedID and press Enter

Right-click the Table1 and click Design View

Set the name of the table to JobsPerformed

Click OK

Complete the table with the following fields:

Field Name

Data Type

Field Size

Format

Caption

JobPerformedID

Job ID

RepairOrderID

Number

Long Integer

RepairOrderID

JobPerformed

100

Job Performed

JobPrice

Number

Double

Currency

Job Price

Save and close the table

Creating a Relationship

To have a meaningful subform (or subreport), there
must be a relationship between the record source (table or query) of the
subform (or subreport) and the record source (table or query) of the
subform (or subreport).

Practical
Learning: Creating a Relationship

On the Ribbon, click Database Tools

In the Relationships section, click Relationships

On the dialog box, double-click Parts Used

Double-click RepairOrders

Double-click JobsPerformed

Click Close

In the RepairOrders table, drag RepairOrderID and drop it on top
of RepairOrderID on the PartsUsed table

From the Fields list, drag RepairOrderID and drop in the Detailt
section of the form

Click its accompanying lable and press Delete

Design the subform as follows:

Save and close the form

Creating the Hosting Form

After creating a sub-form, you must create the form
that will host it. The form is a normal form whose Record Source has a
field that is related to the subform. To create the sub-form, you can use
a wizard.

Practical
Learning: Creating a Form

On the Ribbon, click Create

In the Forms section, click Form Design

Right-click the form and click Form Header/Footer

Click the button at the intersection of the rulers

In the Property Sheet, click Data

Set the Record Source to RepairOrders

Save the form as RepairOrders

Design the form as follows:

From the Naviagation Pane, drag sbfPartsUsed and drop it in the
Parts Used section of the form

From the Naviagation Pane, drag sbfJobsPerformed and drop it in
the Jobs Performed section of the form

Complete the design of the form as follows:

Save the form

To preview it, right-click its tab and click Form View

Create a record as follows:

Close the form

Creating a Sub-Report

A subreport also starts like a normal report. If you
plan to perform calculations on the subreport, you should (must) add the