Syncronized Subforms

Subforms are one of the more convenient features of Access. When one form (a subform) is nested inside another form (a main form), Access can keep the subform's data synchronized with the main form by using a common field to relate the two. In a typical example, the main form might be based on a Customers table and a subform could be based on an Orders table. As records are scrolled in the main form, Access filters the subform so that only relevant orders are displayed for that particular customer.

A subform can also be synchronized with another subform. This technique is demonstrated in the Customer Orders form of the Northwind.mdb sample file and illustrated in Figure 10-7.

The first subform is based on order data and is linked to the main form by CustomerID. The second subform contains order details data and is linked to the first subform by the OrderID field. The mechanism Access uses to synchronize a subform relies on the Link Child Fields and Link Master Fields properties of the subform control. Although a wizard can be used to set up a nested subform that is linked to its parent form, subforms that link to another subform must be set up manually to synchronize. In this case, the Link Master Fields property should be the following:

[Customer Orders Subform1].Form![OrderID]

gä Customer Orders uns

■Company Name Alfreds l uKerkisle

Country Germany

Click an order..

■Company Name Alfreds l uKerkisle

Country Germany

Click an order..

Order ID

Order Date

Kequired Date

Shipped Date

10643

25-Aug-1997

22-Sep-1997

02-Sep-1997

10692

03-Gct-1997

31 -0ct-1997

13-Oct-1997

¡Qglg

13-Oct-1997

24-Nov-1997

21-Oct-1997

10035

15-Jan-13SG

12-F eb-1998

21 -Jari-199B

H

<1

I

.to see order details.

Product Name

Unit Price

Quantity

Discount

Extended Price

Lakkalikoori

$18.00

15 0%'

$270.00

Aniseed Syrup

$10.00

6 0%

0 0

Post a comment