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

ID: Q208826


The information in this article applies to:

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

This article applies to a Microsoft Access database (.mdb) and 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:


  3. KeyPreview: Yes
    OnKeyDown: [Event Procedure]
  4. 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:


  5. 
    Case 27, 33, 34 
  6. 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.

Additional query words: inf


Keywords          : kbdta FmsHowto 
Version           : WINDOWS:2000
Platform          : WINDOWS 
Issue type        : kbhowto 

Last Reviewed: August 8, 1999