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

Last reviewed: August 29, 1997
Article ID: Q156222
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.

  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 following properties of the TabStrip control:

    Custom Control:

             Name: oleTab
             Width: 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. 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
    
    

  16. Set the KeyPreview property of the form to Yes.

  17. 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

  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.

REFERENCES

For more information about using access keys, search for "access keys" using the Microsoft Access for Windows 95 Help Index.


Additional query words: shortcut accelerator

Keywords : IntpCstm kbinterop PgmHowTo FmsEvnt
Version : 7.0
Platform : WINDOWS
Hardware : x86
Issue type : kbbug
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.