Microsoft KB Archive/156222

= ACC95: Access Keys Do Not Work with Tabs on TabStrip Control =

Article ID: 156222

Article Last Modified on 9/13/2006

-

APPLIES TO


 * Microsoft Access 95 Standard Edition

-



This article was previously published under Q156222



Moderate: Requires basic macro, coding, and interoperability skills.



SYMPTOMS
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"

</li> Using the right mouse button (right-click), click the TabStrip control, point to TabStrip Control Object, and then click Properties.</li> In the TabStrip Control Properties dialog box, click the Tabs tab.</li> For Index 1, set the Caption property to &Apple .</li> Click Insert Tab.</li> For Index 2, set the Caption property to &Banana .</li> Click Insert Tab.</li> For Index 3, set the Caption property to &Cherry .</li> Click OK.</li>  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 </li> Set the KeyPreview property of the form to Yes .</li> 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.</li></ol>

<div class="status_section">

STATUS
Microsoft has confirmed this to be a problem in Microsoft Access 7.0. This problem no longer occurs in Microsoft Access 97.

<div class="moreinformation_section">

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

 * 1) Open the sample database Northwind.mdb.
 * 2) Create a new form in Design view.
 * 3) On the Insert menu, click Custom Control.
 * 4) In the Insert OLE Custom Controls dialog box, click TabStrip Control, and then click OK.
 * 5) On the View menu, click Properties.
 * 6) Set the Width property of the TabStrip control to 2.5".
 * 7) Using the right mouse button (right-click), click the TabStrip control, point to TabStrip Control Object, and then click Properties.
 * 8) In the TabStrip Control Properties dialog box, click the Tabs tab.
 * 9) For Index 1, set the Caption property to &Apple.
 * 10) Click Insert Tab.
 * 11) For Index 2, set the Caption property to &Banana.
 * 12) Click Insert Tab.
 * 13) For Index 3, set the Caption property to &Cherry.
 * 14) Click OK.
 * 15) 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.

<div class="references_section">