The information in this article applies to:
- Microsoft Access versions 7.0, 97
SUMMARY
Advanced: Requires expert coding, interoperability, and multiuser skills.
This article demonstrates 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 - 4 for the Customers table.
- Save the form as frmCustomers and close the form.
- Click the Forms tab and create a blank form in Design view.
- On the File menu, click Save As/Export and save the form as
frmTabStrip.
- Insert the TabStrip ActiveX control and set its properties as follows:
Name: ctlTabStrip
Width: 6
Height: 3.5
- 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.
- In the TabStrip Control Properties dialog box, click the Tabs tab.
- Note that the Index is 1. Type "Customers" (without the quotation
marks) in the Caption box.
- Click the Insert Tab button to insert a new Tab.
- Note that the Index changes to 2. Type "Suppliers" (without the
quotation marks) in the Caption box.
- Click OK to close the Property dialog box.
- 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.
- Press F11 to bring the Database window to the foreground.
- 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.
- Select and then delete the subform's label.
- 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
- 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
- On the Run menu, click Compile Loaded Modules. If there are no
compile errors save the form.
- Open the form in Form view.
- Click the Customers tab to display the frmCustomers form. Click the
Suppliers tab to display the frmSuppliers tab.
REFERENCES
For more information about the TabStrip ActiveX control, search on
"TabStrip Control" using the Microsoft Office 97, Developer Edition
help index.