ACC: Disable PAGE UP and PAGE DOWN Keys in a Form (95/97)
ID: Q132031
|
The information in this article applies to:
-
Microsoft Access versions 7.0, 97
SUMMARY
Moderate: Requires basic macro, coding, and interoperability skills.
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:
Q150895 ACC95: Microsoft Access Sample Forms Available in Download Center
Q175066 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 : FmsHowto
Version : 7.0 97
Platform : WINDOWS
Issue type : kbhowto
|