Microsoft KB Archive/132031

= ACC: Disable PAGE UP and PAGE DOWN Keys in a Form (95/97) =

Article ID: 132031

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q132031



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



SUMMARY
This article describes how you can disable the PAGE UP and PAGE DOWN keys in a form by using the new KeyPreview property of forms that was introduced in Microsoft Access 7.0.

NOTE: This article explains a technique demonstrated in the sample files, FrmSampl.exe (for Microsoft Access for Windows 95 version 7.0) and FrmSmp97.exe (for Microsoft Access 97). For information about how to obtain these sample files, please see the following articles in the Microsoft Knowledge Base:

150895 ACC95: Microsoft Access Sample Forms Available in Download Center

175066 ACC97: Microsoft Access 97 Sample Forms Available in Download Center



MORE INFORMATION
To disable the PAGE UP and PAGE DOWN keys in a form, follow these steps:

  Open any database, open any form in Design view, and set the form's properties 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 notice that the PAGE UP and PAGE DOWN keys have no effect.

REFERENCES:
For more information about the KeyPreview property, search for "KeyPreview property," using the Microsoft Access 97 Help Index.

Keywords: kbhowto KB132031

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.