You are currently offline, waiting for your internet to reconnect

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

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.
This article describes how you can disable the PAGE UP and PAGE DOWN keysin a form by using the new KeyPreview property of forms that was introducedin Microsoft Access 7.0.

NOTE: This article explains a technique demonstrated in the samplefiles, FrmSampl.exe (for Microsoft Access for Windows 95 version 7.0)and FrmSmp97.exe (for Microsoft Access 97). For information about howto obtain these sample files, please see the following articles in theMicrosoft 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.


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

Article ID: 132031 - Last Review: 10/26/2013 13:09:00 - Revision: 4.0

Microsoft Access 97 Standard Edition

  • kbnosurvey kbarchive kbhowto KB132031