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



The information in this article applies to:

  • Microsoft Access 2000

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:
  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.

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.

Modification Type:MajorLast Reviewed:12/12/2002
Keywords:kbdta kbhowto KB208826