Results 1 to 10 of 10
  1. #1
    GeekInOhio's Avatar
    GeekInOhio is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    25

    Question Use Hot Key on button without any text?

    I have a bit of an oddball problem.

    I have a couple of buttons that are used for going to the previous/next week on a calendar form. The buttons have no caption, just the built-in Previous Next images. I have a couple of users that are keyboard driven, and they have requested hot keys to trigger these commands.

    Obviously, I could just add text captions and use the ampersand, but for ascetic reasons, I'd prefer not to. So, does anyone know of a way to attach a hot key to a button without having a text caption on it?

    Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    What I do and the only way I know is to give the button an associated label control and hot key the label caption.
    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.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    You can use the Form_KeyDown event to assign your hotkeys, then when the combination is keyed, simply Call the OnClick event of the Target Command Button.

    In Form Design View, go to Properties - Events and set the KeyPreview Property to YES. Then use something like this:

    Code:
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
     If Shift = acAltMask And KeyCode = vbKeyB Then
       Call TargetCommandButton_Click
     End If
    End Sub


    In the above, by pressing

    <Alt> + <B>

    you fire the code residing behind the Command Button named TargetCommandButton.

    You can use combinations with the <SHIFT> key and <CTRL> key, as well as the <Alt> key:

    The bit mask for the <SHIFT> key: acShiftMask
    The bit mask for the <CTRL> key: acCtrlMask
    The bit mask for the <ALT> key: acAltMask

    An alternative, if you were only dealing with a single Command Button, would be to use the Default Property of the Button. Selecting the Command Button and going to Properties - Other and setting the Default Property to Yes, you could then trigger the Command Button by pressing the <Enter> key.

    Linq ;0)>

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    What clue do users have for what key activates which button? Still need some kind of label on the form?
    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
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by June7 View Post
    What clue do users have for what key activates which button? Still need some kind of label on the form?
    The entire point of Hotkeys is that it's a shortcut to an action that power users know by heart, without needing to refer to an instructional Label or dropping down a Menu.

    I should have added to my post that you need to be careful, when deciding on your hotkey combination, not to use one that is already assigned by Access itself. This is particularly important when dealing with 'keyboard driven' end users.

    Linq ;0)>

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Agreed but there is always a 'memorization' curve for new users. I have some forms with buttons using icons because pictures are a mnemonic tool that make it easier to remember button locations and quickly select and those buttons have an associated label with hotkey for those users who prefer not to mouse. Since the hotkey is right in front of them I don't have to teach new users the set of hotkeys or give them a cheat sheet to memorize. Then I try to teach the clickers about hotkeys and since the hotkeys are displayed they eventually convert (especially after I slap their mouse hand a few times - LOL). Something for everyone and no burden on me to maintain and distribute cheat sheet.
    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.

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Agreed right back at you! But this, according to the OP, is being done at the request of some of the end users! I suspect he could care less about forcing those not interested in the hotkeys to use them!

    Quote Originally Posted by GeekInOhio View Post
    ...I have a couple of users that are keyboard driven, and they have requested hot keys to trigger these commands.
    To be honest, I'm from the pre-Windows era, when everything was done through the keyboard, but stopped doing most things that way a long time ago! I can't imagine users, even 'production-line' users, who'd rather press two keys than click on a button sitting right there in front of them! Doing it to avoid dropping a menu down and clicking on an option I can see, maybe even right-clicking and clicking on an option, but not a simple 'click on the button right there in front of you!'

    But, to each his/her own! When you think about it, making apps user-friendly, within limits, is what programming is all about!

    Linq ;0)>

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Personally, I find it more efficient to press two keys then to take hand off keyboard, go to mouse, move cursor, click then find my hand position back on the keyboard, multiple times on a form. Drives me nuts when I am helping a user and watch them do this ping pong exercise. Actually, most of the ping ponging is due to combo and list boxes so I really go insane watching user do this instead of taking advantage of combo and list box features like AutoExpand, and tab/enter to progress through the form. Arrrrgh!

    So I offer hotkeys, either directly on the button or with associated label and educate all users on use. I have many forms that can be completed without ever touching the mouse. A form button (activated by Alt+key) can open another form and that form can be completed then even closed, all without leaving the keyboard.

    A strictly 'menu' form, one without data controls to get focus, doesn't even need the Alt key press to activate the hotkey, just press the letter key.

    BTW, I remember DOS, too, and BASIC, well, at least I remember using them, details are long gone!
    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.

  9. #9
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    You just don't remember that you remember the details! You use a huge number of them every day, because BASIC begat QBasic, which begat QuickBasic, which, when coupled with Tripod/Ruby, begat Visual Basic and then...tada! VBA for Access!

    Actually, I probably use hotkeys for 90+ per cent of my input stuff. The problem, sadly, is that most end users are not power users, at least not in my user populations, which were in the health care industry! They had to be pulled, kicking and screaming, into the brave, new world of Information Technology, and the closer to video game the apps were, the better!

    Have a great holiday weekend!

    Linq ;0)>

  10. #10
    GeekInOhio's Avatar
    GeekInOhio is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    25
    After some muddling about I opted to bind labels and shortcut from there. Thanks to both of you for taking the time to throw some ideas out, including my eventual solution.

    As this spurred a bit of a discussion, in my case my user base is 250 strong, and predominantly on their first job out of college. My biggest challenge most days is explaining why they can't use the DB via their phone. In the management ranks, I have a few grizzled vets who cut their teeth on terminal environments sans mouse, and it is this group requesting the keyboard shortcuts.

    Given my dithers, I tend to lean towards shortcuts. But since my user base is so overwhelmingly point-and-click driven, I try to use the tool the same way they do to get a better feel for their points of frustration.

    Again, thanks for the help!

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

Similar Threads

  1. Bind item() to button text at random
    By timosilver in forum Access
    Replies: 0
    Last Post: 02-26-2012, 12:08 PM
  2. Populate text boxes with a command button
    By Brian62 in forum Forms
    Replies: 3
    Last Post: 09-30-2011, 12:52 PM
  3. Replies: 1
    Last Post: 09-20-2011, 05:57 AM
  4. Making a toggle button hide a text box.
    By RemonKoybito in forum Forms
    Replies: 3
    Last Post: 05-20-2011, 11:34 AM
  5. Cmd Button/ Text box verification
    By kaylachris in forum Forms
    Replies: 2
    Last Post: 05-19-2010, 11:06 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