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

Last reviewed: October 24, 1997
Article 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 using the new KeyPreview property of forms 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:

   ARTICLE-ID: Q150895
   TITLE     : ACC95: Microsoft Access Sample Forms Available on MSL

   ARTICLE-ID: Q175066
   TITLE     : ACC97: Microsoft Access 97 Sample Forms Available on MSL

MORE INFORMATION

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

  1. Open any database, open any form in Design view, and set the form's properties as follows:

          KeyPreview: Yes
          OnKeyDown: [Event Procedure]
    

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

  3. 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 kbusage
Version           : 7.0 97
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 24, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.