ACC2: How to Disable PAGE UP and PAGE DOWN Keys in a FormLast reviewed: May 13, 1997Article ID: Q114506 |
The information in this article applies to:
SUMMARYModerate: Requires basic macro, coding, and interoperability skills. This article describes the following two methods that you can use to disable the PAGE UP and PAGE DOWN keys in a form:
MORE INFORMATION
Method 1: Opening the Form as Dialog Using the OpenForm Macro ActionThe PAGE UP and PAGE DOWN keys will be inoperative in a form if the form is opened using an OpenForm macro action with the Window Mode argument set to Dialog. To demonstrate this technique, create and run a new macro with the following actions in the sample database NWIND.MDB.
OpenForm Form Name: Customers Filter Name: <leave empty> Where Condition: <leave empty> View: Form Data Mode: Edit Window Mode: DialogThe drawback to this technique is that a Dialog form cannot use a custom menu, nor will you be able to switch to another form while the Dialog form is open. NOTE: The Microsoft Access Wizards use this technique to limit navigation in multiple-page forms.
Method 2: Trapping PAGE UP and PAGE DOWN in the KeyDown EventThe PAGE UP and PAGE DOWN keys can be detected and trapped in a control by adding the following lines of Access Basic code to the KeyDown event for all the controls on a form where the PAGE UP and PAGE DOWN keys should be disabled:
If KeyCode = KEY_PRIOR Or KeyCode = KEY_NEXT Then KeyCode = 0 End IfNOTE: The constants for KeyCode are defined in the CONSTANT.TXT file, which is included with Microsoft Access. To use these constants in your code, you must either declare them yourself or copy them from the CONSTANT.TXT file and paste them into the Declarations section of your module. The following example demonstrates how to detect and trap the PAGE UP and PAGE DOWN keys in a control's KeyDown event. CAUTION: Following the steps in this example will modify the sample database NWIND.MDB. You may want to back up the NWIND.MDB file, or perform these steps on a copy of the NWIND database.
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) Select Case KeyCode Case 27, 34, 33 KeyCode = 0 End Select End Sub REFERENCESFor more information about disabling PAGE UP and PAGE DOWN in Microsoft Access 95 and 97, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q132031 TITLE : ACC: How to Disable PAGE UP and PAGE DOWN Keys in a Form (95/97)For more information about Dialog forms, search for "OpenForm," and then "OpenForm Action" using the Microsoft Access Help menu. For more information about the KeyDown event, search for "KeyDown," and then "KeyDown, KeyUp Events" using the Microsoft Access Help menu.
|
Additional query words: pgup pgdn
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |