Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: How to Disable PAGE UP and PAGE DOWN Keys in a Form


View products that this article applies to.

Summary

This article describes how you can disable the PAGE UP and PAGE DOWN keys in a form by using the KeyPreview property of forms.

↑ Back to the top


More information

To disable the PAGE UP and PAGE DOWN keys in a form, follow these steps:
  1. Open any database, and then open any form in Design view.
  2. Set the properties of the form as follows:
    KeyPreview: Yes
    OnKeyDown: [Event Procedure]
  3. 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
    					
  4. Open the form in Form view and note that pressing the PAGE UP and PAGE DOWN keys has no effect.

↑ Back to the top


References

For more information about the KeyPreview property, click Microsoft Access Help on the Help menu, type keypreview property in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

↑ Back to the top


Keywords: KB208826, kbdta, kbhowto

↑ Back to the top

Article Info
Article ID : 208826
Revision : 1
Created on : 12/12/2002
Published on : 12/12/2002
Exists online : False
Views : 241