Results 1 to 6 of 6
  1. #1
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727

    Disable certain keys

    Everywhere I look online, it tells me how to disable all ctrl shortcut keys but the thing is I would like to keep some active. So I need some help for the vba to pick which ctrl shortcut keys I would like to disable. One of the few ctrl shortcuts I do want to disable is the Ctrl+P shortcut key to print. I would also like to disable all the F1-F12 keys if its possible to add it into the code.

    Some of the keys I would like to keep are Ctrl+C and V to copy and paste.



    I was thinking of just going down the list of shortcut keys and deciding if I want to disable them or not. So its important in the code that I get to pick and choose which ones I want to disable.

    I know hardly anything of vba and would really appreciate the help.

    Thanks.

  2. #2
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    I got this code to work but it cancels ALL CTRL shortcut keys because it basically cancels out the CTRL button all together. I would still like to use the CTRL+C and CTRL+V and maybe even a couple more shortcuts. How do I get it to enable those?

    If (Shift And acCtrlMask) > 0 Then
    KeyCode = 0
    Shift = 0
    End If

  3. #3
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    This also works really well but I can't figure out how to add more buttons to this code. 80 = the P key on the keyboard.

    If (Shift And acCtrlMask) > 0 And KeyCode = 80 Then KeyCode = 0

    I found a list that says the letter S key is = to 83. How would I add that to the code?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,945
    The only macro I have ever used is an Autokeys macro. I couldn't find any other way to disable Ctrl+P for the entire db to prevent shortcut printing.

    http://office.microsoft.com/en-us/ac...010239111.aspx

    Maybe you want:

    If (Shift And acCtrlMask) > 0 And (KeyCode = 80 Or KeyCode = 83) Then KeyCode = 0

    Or use an If Then Else
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    I haven't tried the parenthesis but have tried the If, Then, Else, Else If, Or, And, +, etc... Pretty much everything you can think of. Either it runs into an error or it disables the second key (S) totally and I can no longer type the letter S. I'll try the parenthesis and let you know.

  6. #6
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    Thanks June7. The parenthesis worked great. Just gotta manually add all the buttons to it and it should be good to go. Thanks again.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Same Items Different Keys?
    By anonymust in forum Database Design
    Replies: 8
    Last Post: 12-16-2013, 04:53 PM
  2. Registry keys
    By ashu.doc in forum Access
    Replies: 1
    Last Post: 10-27-2012, 12:19 AM
  3. question about keys
    By johny in forum Access
    Replies: 3
    Last Post: 03-24-2012, 06:57 AM
  4. Need help with foreign keys
    By acdougla17 in forum Access
    Replies: 1
    Last Post: 09-26-2011, 03:50 PM
  5. Tab or Enter keys
    By rwatkins in forum Forms
    Replies: 3
    Last Post: 05-11-2011, 03:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums