ACC2000: How to Use the Tab Control with Linked Subforms
ID: Q198502
|
The information in this article applies to:
Novice: Requires knowledge of the user interface on single-user computers.
This article applies to a Microsoft Access database (.mdb) and a Microsoft Access project (.adp).
SUMMARY
You can use the tab control to display linked subforms. A form contains
linked subforms when the second subform displays only the records related
to the record that you select in the first subform. The Customer Orders
form in the sample database Northwind.mdb has an example of linked
subforms.
Because a tab control enables you to place different controls on
different pages of a single control, you can make better use of available
space on the main form and still have plenty of room to display the
subforms.
MORE INFORMATION
The following example demonstrates how to create a form with two linked
subforms similar to those on the Customer Orders form. The tab control on
the main form contains one of the linked subforms on each of its two pages.
- Open the sample database Northwind.mdb.
- Create a new form in Design view based on the Customers table. Save the form as frmMain.
- If the field list is not visible, click Field List on the View menu.
- Drag CustomerID to the upper-left corner of the detail section; drag CompanyName to the upper-right corner of the detail section.
- Click the Tab Control tool in the toolbox, and then click under the CustomerID field in the detail section of the form to create the tab control.
- Set the following properties for the tab control:
Left: 0"
Top: 0.25"
Width: 6"
Height: 3"
- Click the leftmost page, or tab, of the control. On the View menu, click Properties. Change the name of the page to Orders.
- Click the Subform/Subreport tool in the toolbox.
- Move your pointer over the body of the Orders page. Note that the page changes color. This ensures that you are placing the subform on that page instead of simply laying it on top of the tab control. Click to add a subform to the page.
- On the first screen of the Subform/Subreport Wizard, click Forms and select Customer Orders Subform1 from the list. Click Next.
- When you are asked if you would like to define which fields link your
main form to this subform, click Choose from a list and select Show Orders for each record in Customers using CustomerID. Click Finish.
- On the View menu, click Properties. Set the following properties:
Left: 0.5"
Top: 0.75"
Width: 3.5"
Height: 1.5"
- Click the rightmost page of the control. On the View menu, click Properties. Change the name of the page to Order Details.
- Click the Subform/Subreport tool in the toolbox.
- Move your pointer over the body of the Orders Details page. Note that the page changes color. Click to add a subform to the page.
- On the first screen of the Subform/Subreport Wizard, click Forms and select Customer Orders Subform2 from the list. Click Finish.
- On the View menu, click Properties. Set the following properties:
LinkChildFields: OrderID
LinkMasterFields: [Customer Orders Subform1].[Form]![OrderID]
Left: 0.5"
Top: 0.75"
Width: 5.5"
Height: 1.5"
- On the View menu, click Form View.
Note that as you select different Order IDs on the Orders page, only the
products for that particular order are displayed on the Order Details page.
REFERENCES
For more information about the tab control, please see the following article in the Microsoft Knowledge Base:
Q208785
ACC2000: How to Use the Tab Control in Access
Additional query words:
inf
Keywords : kbdta FmsSubf
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: June 10, 1999