ACC2: KeyDown and KeyPress Events Do Not Run in Option Group

Last reviewed: May 14, 1997
Article ID: Q132330
The information in this article applies to:
  • Microsoft Access version 2.0

SYMPTOMS

Novice: Requires knowledge of the user interface on single-user computers.

When you try to trap keystrokes using event procedures for the OnKeyDown or the OnKeyPress property of a control within an option group in a subform, the keystroke events do not occur. As a result, you cannot disable keystrokes, such as PAGE UP and PAGE DOWN, from within an option group in a subform.

STATUS

Microsoft has confirmed this to be a problem in Microsoft Access version 2.0. This problem no longer occurs in Microsoft Access version 7.0. Also, in version 7.0, you can use the KeyPreview property to trap for keystrokes before a form control receives notification of the keystrokes. This enables you to disable keystrokes regardless of the form controls.

MORE INFORMATION

Steps to Reproduce Problem

  1. Create a new, blank form and name it TestForm.

  2. Add an option group control to the TestForm form and add two option buttons to the option group control. Set the option buttons' properties as follows:

    Option button:

              Name: Button1
              OptionValue: 1
           Option button:
              Name: Button2
              OptionValue: 2
    
    

  3. Set the Button1 control's OnKeyDown property to the following event procedure:

    MsgBox "The KeyDown event fired for Button1."

  4. Set the Button2 control's OnKeyPress property to the following event procedure:

    MsgBox "The KeyPress event fired for Button2."

  5. Close and save the TestForm form.

  6. Create a new, blank form named TestForm2 and open it in Design view.

  7. Press the F11 key to display the Database window. Click the Form tab, and then drag the TestForm form to the detail section of the TestForm2 form to create a subform control.

  8. View the TestForm2 form in Form view.

  9. Click the Button1 control and press any key. Note that the message box does not appear.

  10. Click the Button2 control and press any key. Note that the message box does not appear.

REFERENCES

For more information about the KeyDown event, search for "KeyDown," and then "KeyDown, KeyUp Events" using the Microsoft Access Help menu.

For more information about disabling the PAGE UP and PAGE DOWN keys in a form, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q114506
   TITLE     : ACC2: How to Disable PAGE UP and PAGE DOWN Keys in a Form
 

	
	


Keywords : FmsOpt kbusage
Version : 2.0
Platform : WINDOWS
Hardware : X86
Issue type : kbbug
Resolution 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: May 14, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.