Disable PageUp/PageDown with VBA

Posted on 2009-04-18
Last Modified: 2013-11-28
When a "Single Form" is active and displays fields related to one record of it's underlying table, pressing Page Down advances to the next record and Page Up it's preceding.

Is there code that disables this?  I want to be able to toggle the enabling and disabling of these hardware buttons based on the admin/non-admin status of users as logged into my application.  In other words, non-admin users will not be able to use Page Up nor Page Down but admins will.

Question by:Greg-C
    LVL 65

    Expert Comment

    In the keydown event, check for page up and page down. then the key that is pressed, set to 0 so it kinda disables it


    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = vbKeyPageUp Or KeyCode = vbKeyPageDown Then
            KeyCode = 0
        End If
    End Sub
    LVL 65

    Expert Comment

    forgot your user check

    if currentuser = "Admin" and (If KeyCode = vbKeyPageUp Or KeyCode = vbKeyPageDown) then
    LVL 65

    Accepted Solution

    Another thing I forgot, you need to set the form's key preview to yes. This is found in the properties when viewing form in design view

    Author Closing Comment

    This is exactly what I was looking for.  Thanks for your help today!

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
    Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now