Microsoft KB Archive/208826

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

Article ID: 208826

Article Last Modified on 12/12/2002

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q208826



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



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.



MORE INFORMATION
To disable the PAGE UP and PAGE DOWN keys in a form, follow these steps:  Open any database, and then open any form in Design view. Set the properties of the form as follows:

KeyPreview: Yes

OnKeyDown: [Event Procedure]

  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  Open the form in Form view and note that pressing the PAGE UP and PAGE DOWN keys has no effect.

