?
Solved

Disable PageUp/PageDown with VBA

Posted on 2009-04-18
4
Medium Priority
?
1,408 Views
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.

Thanks
0
Comment
Question by:Greg-C
  • 3
4 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 24175337
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

eg

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

Expert Comment

by:rockiroads
ID: 24175344
forgot your user check

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

Accepted Solution

by:
rockiroads earned 2000 total points
ID: 24175362
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
0
 

Author Closing Comment

by:Greg-C
ID: 31571780
This is exactly what I was looking for.  Thanks for your help today!
GregC
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

840 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