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