ACC: Disable PAGE UP and PAGE DOWN Keys in a Form (95/97)

Article translations Article translations
Article ID: 132031 - View products that this article applies to.
This article was previously published under Q132031
This article has been archived. It is offered "as is" and will no longer be updated.
Moderate: Requires basic macro, coding, and interoperability skills.
Expand all | Collapse all

On This Page

Summary

This article describes how you can disable the PAGE UP and PAGE DOWN keys in a form by using the new KeyPreview property of forms that was introduced in Microsoft Access 7.0.

NOTE: This article explains a technique demonstrated in the sample files, FrmSampl.exe (for Microsoft Access for Windows 95 version 7.0) and FrmSmp97.exe (for Microsoft Access 97). For information about how to obtain these sample files, please see the following articles in the Microsoft Knowledge Base:

150895 ACC95: Microsoft Access Sample Forms Available in Download Center

175066 ACC97: Microsoft Access 97 Sample Forms Available in Download Center

More information

To disable the PAGE UP and PAGE DOWN keys in a form, follow these steps:
  1. Open any database, open any form in Design view, and set the form's properties as follows:
          KeyPreview: Yes
          OnKeyDown: [Event Procedure]
    						
  2. Click the Build button to the right of the OnKeyDown property and type the following procedure:
          Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
             Select Case KeyCode
                Case 33, 34
                   KeyCode = 0
             End Select
          End Sub
    						

    NOTE: KeyCodes 33 (&H21) and 34 (&H34) represent PAGE UP and PAGE DOWN, respectively. You can disable other keys on the form by including the appropriate KeyCode in the Case statement. For example, if you also want to disable the ESC key on the form, add KeyCode 27 to the Case statement as follows:
          Case 27, 33, 34
    						
  3. Open the form in Form view and notice that the PAGE UP and PAGE DOWN keys have no effect.

REFERENCES:

For more information about the KeyPreview property, search for "KeyPreview property," using the Microsoft Access 97 Help Index.

Properties

Article ID: 132031 - Last Review: October 26, 2013 - Revision: 4.0
Applies to
  • Microsoft Access 97 Standard Edition
Keywords: 
kbnosurvey kbarchive kbhowto KB132031

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com