Results 1 to 6 of 6
  1. #1
    Join Date
    May 2005
    Posts
    1,191

    Unanswered: Disable Ctrl+Tab on Tab Control

    I have a tab control on a form. It's basically a switchboard form, where each tab is for a different level of user (admin, editor, manager, generic user, etc). I have the tab control's Style property set to None, and the form automatically pulls up the appropriate tab for the user based on their login ID and referencing a user table. This all works fine.

    What I'd like to do is to make sure a "smart" generic user can't ctl+tab to the admin tab by disabling this shortcut. Does anyone know how?

    I tried turning off the Allow Windows Shortcut Keys option in the Startup interface, but this did nothing. I found this article, but I couldn't get it to work. Has anyone gotten this to work, that I'm just being stupid? Or is there a simpler method that I'm missing?
    Me.Geek = True

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    In Design View goto the Form's Properties - Events and set the Key Preview Property to YES.

    Then, in the form's code module:

    Code:
    Private Sub form_keydown(KeyCode As Integer, Shift As Integer)
      If Shift = 2 And vbKeyTab Then KeyCode = 0
    End Sub
    Now, when you press the <Ctrl> + <Tab> nothing happens!
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    May 2005
    Posts
    1,191
    I had tried something similar with a
    msgbox keypress
    to try and figure out which int was being passed, but it wouldn't trigger when I used ctl+tab, so I couldn't figure out what to use in the if statement.

    Thanks Missinglinq!
    Me.Geek = True

  4. #4
    Join Date
    May 2005
    Posts
    1,191
    I also added:
    Code:
    'disable ctrl+tab on tab control
    If Shift = acCtrlMask And vbKeyTab Then KeyCode = 0
    'disable ctrl+shift+tab on tab control
    If Shift = acCtrlMask + acShiftMask And vbKeyTab Then KeyCode = 0
    for anyone who wants to do something similar. No sense preventing the user from tabbing to the right, if you don't also disable them from tabbing to the left
    Me.Geek = True

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Wow, lovely way of doing this!
    Generally my way (because I'd never seen anything better) was to just create an autokeys macro and make the keystrokes not do anything
    George
    Home | Blog

  6. #6
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    That was my first thought, too, George, but Access threw an error message saying ^{Tab} was an invalid combination in AutoKeys!
    Last edited by Missinglinq; 07-18-07 at 21:04.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •