The information in this article applies to:
- Microsoft Access version 7.0
SYMPTOMS
Moderate: Requires basic macro, coding, and interoperability skills.
When you create an access key by typing an ampersand (&) in front of a
letter in the Caption property of a tab on a TabStrip control, the letter
appears underlined as expected. However, pressing the ALT key plus the
underlined letter fails to select that tab in Form view.
RESOLUTION
The following example shows how you can trap the key strokes in the KeyDown
event of the form, and use them to select the correct tab by changing the
Selected property of the TabStrip 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 the "Building
Applications with Microsoft Access for Windows 95" manual.
- Open the sample database Northwind.mdb.
- Create a new form in Design view.
- On the Insert menu, click Custom Control.
- In the Insert OLE Custom Controls dialog box, click TabStrip Control,
and then click OK.
- On the View menu, click Properties.
- Set the following properties of the TabStrip control:
Custom Control:
Name: oleTab
Width: 2.5"
- Using the right mouse button (right-click), click the TabStrip control,
point to TabStrip Control Object, and then click Properties.
- In the TabStrip Control Properties dialog box, click the Tabs tab.
- For Index 1, set the Caption property to &Apple.
- Click Insert Tab.
- For Index 2, set the Caption property to &Banana.
- Click Insert Tab.
- For Index 3, set the Caption property to &Cherry.
- Click OK.
- Set the KeyDown property of the form to the following event procedure:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If (Shift and acAltMask) > 0 Then ' ALT key was pressed
Select Case KeyCode
Case vbKeyA ' ALT+A was pressed
oleTab.Tabs(1).Selected = True
Case vbKeyB ' ALT+B was pressed
oleTab.Tabs(2).Selected = True
Case vbKeyC ' ALT+C was pressed
oleTab.Tabs(3).Selected = True
End Select
End If
End Sub
- Set the KeyPreview property of the form to Yes.
- Switch the form to Form view. Note that when you press ALT+A, ALT+B,
and ALT+C, the corresponding TabStrip control tab is selected.
STATUS
Microsoft has confirmed this to be a problem in Microsoft Access 7.0.
This problem no longer occurs in Microsoft Access 97.
MORE INFORMATION
You need the Microsoft Access Developer's Toolkit for Windows 95 to use the
TabStrip control. The TabStrip control gives you the same features as the
tabbed dialog boxes available in many Windows 95 applications, such as the
Page Setup dialog box on the File menu in Microsoft Access for Windows 95.
Steps To Reproduce Problem
- Open the sample database Northwind.mdb.
- Create a new form in Design view.
- On the Insert menu, click Custom Control.
- In the Insert OLE Custom Controls dialog box, click TabStrip Control,
and then click OK.
- On the View menu, click Properties.
- Set the Width property of the TabStrip control to 2.5".
- Using the right mouse button (right-click), click the TabStrip control,
point to TabStrip Control Object, and then click Properties.
- In the TabStrip Control Properties dialog box, click the Tabs tab.
- For Index 1, set the Caption property to &Apple.
- Click Insert Tab.
- For Index 2, set the Caption property to &Banana.
- Click Insert Tab.
- For Index 3, set the Caption property to &Cherry.
- Click OK.
- Switch the form to Form view. Try to select tabs on the form by
pressing ALT+A, ALT+B, and ALT+C. Note that the tab selection does
not change.
REFERENCES
For more information about using access keys, search for "access keys"
using the Microsoft Access for Windows 95 Help Index.
|