Microsoft KB Archive/155646

= ACC: How to Use the TabStrip ActiveX Control =

Article ID: 155646

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q155646



Advanced: Requires expert coding, interoperability, and multiuser skills.



SUMMARY
This article shows you how to use the TabStrip ActiveX control in the sample database Northwind to view the Customers and the Suppliers tables using the SourceObject property of a subform.

In Microsoft Access 97, you can use the built-in Tab control on a form to display table data instead of the TabStrip ActiveX control.

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual.



MORE INFORMATION
To use a TabStrip ActiveX control to view the Customers and the Suppliers tables follow these steps:  Open the sample database Northwind.mdb. Click the Tables tab and highlight the Suppliers table. On the Insert Menu, click AutoForm to create a form based on the Suppliers table. On the File menu, click Save As/Export. Save the form as frmSuppliers and close the form. Repeat steps 2 through 4 for the Customers table.</li> Save the form as frmCustomers and close the form.</li> Click the Forms tab and create a blank form in Design view.</li> On the File menu, click Save As/Export and save the form as frmTabStrip.</li> Insert the TabStrip ActiveX control and set its properties as follows:

Name: ctlTabStrip

Width: 6

Height: 3.5

</li> Using the right mouse button, click the TabStrip control object, point to TabStrip Control Object, and then click Properties on the shortcut menu that appears.</li> In the TabStrip Control Properties dialog box, click the Tabs tab.</li> Note that the Index is 1. Type "Customers" (without the quotation marks) in the Caption box.</li> Click the Insert Tab button to insert a new Tab.</li> Note that the Index changes to 2. Type "Suppliers" (without the quotation marks) in the Caption box.</li> Click OK to close the Property dialog box.</li> Make sure your form is not maximized. If your form is maximized, click the button to the left of the File menu, and then click Restore on the shortcut menu that appears.</li> Press F11 to bring the Database window to the foreground.</li> Click the Forms tab and drag the frmCustomers form from the Database window to the frmTabStrip form (displayed in the background) to create a subform.</li> Select and then delete the subform's label.</li> To ensure that the tabs on the TabStrip ActiveX control are not covered by the subform, set the subform's properties as follows:

Top: .3

Width: 6

Height: 3

Left: 0

</li>  Using the right mouse button, click the TabStrip ActiveX control object, and then click Build Event. Type the following event procedure: Private Sub ctlTabStrip_Click On Error GoTo errhandler Dim rs As Recordset, mybookmark As String, I As Integer

Select Case Me!ctlTabStrip.SelectedItem.INDEX Case 1     ' Show Customers form. Customers.SourceObject = "frmCustomers"

Case 2     ' Show Suppliers form. Customers.SourceObject = "frmSuppliers"

End Select Exit Sub

errhandler:

MsgBox "There is an error" Customers.SourceObject = "frmCustomers" End Sub </li> <li>On the Run menu, click Compile Loaded Modules. If there are no compile errors save the form.</li> <li>Open the form in Form view.</li> <li>Click the Customers tab to display the frmCustomers form. Click the Suppliers tab to display the frmSuppliers tab.</li></ol>

<div class="references_section">