ACC2000: How to Use the TabStrip ActiveX Control (209999)



The information in this article applies to:

  • Microsoft Access 2000

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.

  1. Start Microsoft Access and open the sample database Northwind.mdb.
  2. In the Database window, click Tables, and then click Suppliers.
  3. On the Insert menu, click AutoForm to create a form based on the Suppliers table.
  4. On the File menu, click Save As.
  5. Save the form as frmSuppliers and close the form.
  6. Repeat steps 2 through 4 for the Customers table.
  7. Save the form as frmCustomers, and then close the form.
  8. 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.
  9. On the File menu, click Save As, and then save the form as frmTabStrip.
  10. 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

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

    Note that the Index value is 1.
  13. Type Customers in the Caption box.
  14. Click the Insert Tab button to insert a new tab.

    Note that the Index value changes to 2.
  15. Type Suppliers in the Caption box.
  16. 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.
  17. 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.
  18. 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

  19. Select and then delete the subform's label.
  20. 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
    					
  21. 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.
  22. On the View menu, click Form View.
  23. Click the Customers tab to display the frmCustomers form. Click the Suppliers tab to display the frmSuppliers form.

REFERENCES

For more information about the TabStrip ActiveX control, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type activex control properties in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Modification Type:MajorLast Reviewed:6/29/2004
Keywords:kbhowto kbinfo kbprogramming kbusage KB209999