Microsoft KB Archive/209999

= ACC2000: How to Use the TabStrip ActiveX Control =

Article ID: 209999

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q209999



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

This article applies only to a Microsoft Access database (.mdb).



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.



MORE INFORMATION
To use a TabStrip ActiveX control to view the Customers and the Suppliers tables, follow these steps:

CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

NOTE: The sample code in this article uses Microsoft Data Access Objects. For this code to run properly, you must reference the Microsoft DAO 3.6 Object Library. To do so, click References on the Tools menu in the Visual Basic Editor, and make sure that the Microsoft DAO 3.6 Object Library check box is selected.

 Start Microsoft Access and open the sample database Northwind.mdb. In the Database window, click Tables, and then click Suppliers. On the Insert menu, click AutoForm to create a form based on the Suppliers table. On the File menu, click Save As. 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 then close the form.</li> In the Database window, click Forms, and then click New to create a blank form in Design view, not based on any table or query.</li> On the File menu, click Save As, and then save the form as frmTabStrip.</li> On the Insert menu, click ActiveX Control, select Microsoft TabStrip Control, version 6.0, and then set its properties as follows:

Name: ctlTabStrip

Width: 6

Height: 3.5

</li> Right-click the ctlTabStrip control object, point to TabStrip Object, and then click Properties on the shortcut menu that appears.</li> In the TabStrip Control Properties dialog box, click the Tabs tab.

Note that the Index value is 1.</li> Type Customers in the Caption box.</li> Click the Insert Tab button to insert a new tab.

Note that the Index value changes to 2.</li> Type Suppliers in the Caption box.</li> Click OK to close the TabStrip Control Properties dialog box.

Make sure that your form is not maximized. Press F11 to bring the Database window to the foreground.</li> In the Database window, click Forms, and then drag the frmCustomers form from the Database window to the frmTabStrip form (displayed in the background) to create a subform.</li> To ensure that the tabs on the ctlTabStrip control are not covered by the subform, set the subform's properties as follows:

Top: .3

Width: 6

Height: 3

Left: 0

</li> Select and then delete the subform's label.</li>  Right-click the ctlTabStrip control object, and then click Build Event. Type the following event procedure: Private Sub ctlTabStrip_Click On Error GoTo errhandler Dim rs As DAO.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> On the Debug menu, click Compile Northwind. If there are no compile errors, press CTRL+Q to return to Microsoft Access, and then save the form.</li> On the View menu, click Form View.</li> <li>Click the Customers tab to display the frmCustomers form. Click the Suppliers tab to display the frmSuppliers form.</li></ol>

<div class="references_section">