ACC97: How to Use the Tab Control with Linked Subforms

Last reviewed: October 24, 1997
Article ID: Q171222
The information in this article applies to:
  • Microsoft Access 97

SUMMARY

Novice: Requires knowledge of the user interface on single-user computers.

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 you select in the first subform. The Customer Orders form in the sample database Northwind.mdb contains an example of linked subforms.

Because the Tab control allows 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.

NOTE: A demonstration of the technique used in this article can be seen in the sample file, FrmSmp97.exe. For information about how to obtain this sample file, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q175066
   TITLE     : ACC97: Microsoft Access 97 Sample Forms Available on MSL

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.

  1. Open the sample database Northwind.mdb

  2. Create a new form in Design view based on the Customers table. Save the form as frmMain.

  3. If the Field List is not visible, click Field List on the View menu.

  4. Drag CustomerID to the upper-left corner of the detail section; drag CompanyName to the upper-right corner of the detail section.

  5. Click the Tab control tool on the Toolbox, and then click under the CustomerID field in the detail section of the form to create the Tab control.

  6. Set the following properties for the Tab control:

    Left: 0" Top: .25" Width: 6" Height: 3"

  7. Click the leftmost page, or tab, of the control. On the View menu, click Properties. Change the name of the page to "Orders" (without the quotation marks).

  8. Click the Subform/Subreport tool in the Toolbox.

  9. Move your pointer over the body of the Orders page. Notice 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.

  10. In the first screen of the Subform/Subreport Wizard, click Forms and select Customer Orders Subform1 from the list. Click Next.

  11. 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 Customer using CustomerID." Click Finish.

  12. On the View menu, click Properties. Set the following properties:

           Left:     0.5"
           Top:      0.75"
           Width:    3.5"
           Height:   1.5"
    
    

  13. Click the rightmost page of the control. On the View menu, click Properties. Change the name of the page to "Order Details" (without the quoation marks).

  14. Click the Subform/Subreport tool in the Toolbox.

  15. Move your pointer over the body of the Orders Details page. Notice that the page changes color. Click to add a subform to the page.

  16. In the first screen of the Subform/Subreport Wizard, click Forms and select Customer Orders Subform2 from the list. Click Finish.

  17. 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"
    
    

  18. On the View menu, click Form.

Notice 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:

   ARTICLE-ID: Q160127
   TITLE     : ACC97: How to Use the Tab Control in Microsoft Access 97
Keywords          : FmsSubf kbusage
Version           : 97
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 24, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.