Consulting

Results 1 to 10 of 10

Thread: User form hotkeys

  1. #1

    User form hotkeys

    Hi,

    Any way to make a hot key work just from the key press rahter tha having to Alt + key?

    I have several option buttons marked A,B,C etc and have assigned each with the accelerator in properties but would like not to have to use the Alt key as well.

    thanks

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Use OnKey to assign the key to a routine.

  3. #3
    Hi,

    Never used onkwy - any hints on how to assign optionbutton1 using onkey?

    thanks

  4. #4
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    OptionButton1 sounds like a control.
    The help system describes how to use OnKey with all the keys on a standard keyboard, including function keys.

  5. #5
    Doesn't really help much

    expression.OnKey(Key, Procedure)

    Just can't figure this out. May be best not to try since assigning optiobutton to a particular key might mess up the other text box inputs?

  6. #6
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    What is an optionbutton?

    Excel's help system won't let me copy it to paste here, but when I click on the help button in the VBEditor and enter OnKey as a keyword, I get a chart of non standard characters and the way to enter them.

  7. #7
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    ... might mess up the other text box inputs

    Indeed! That's why key modifiers are used.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  8. #8
    Optionbuttons are of course controls in the userform.

    I have 10 'frames' in the user form. Each frame has a combobox (which is linked to a particular worksheet) and then 2 text boxes for inputting amounts. Then there are 6 optionbuttons - optionbutton1, 2 etc labelled B,C,D,E,F,G. Dependent on which is selected determines which column is populated in the sheet selected from the combobox.

    By making the accelerator key in each optionbutton 'match' the optionbutton (label) it is possible while the focus is in the optionbuttons to ALT + B to select optionbutton1, ALT +C to select optionbutton2 etc.

    I was just tring to see if there was a way to not have to select the ALT key i.e. just select the key e.g. B for optionbutton1 to set to true.

    regards

    Jon

  9. #9
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Accelerator keys are standard Windows features and the most likely effect of doing it differently in your form is that users will get confused ("why does it work one way here and another way there?") - all for the sake of saving a key press - not really worth it, I'd say, even if it were otherwise sensible.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  10. #10
    Not an expert by any means and have not come across accelerator keys before - only on this project - nor am I an expert in VBA - in fact probably a novice(well may be a little more now)

    The form is an input mechanism for an investment based log.(15 different funds, several unit classes)

    The comboboxes in each frame point to the sheet associated with the fund. The 2 text boxes are for inputting either GBP or units. The optionbuttons are marked B, C etc and refer to the class type. The user would not get confused because each frame set has to have at least one of the optionbuttons completed before a 'frameset' can be entered.

    At the moment the easiest way appear to be using the mouse & click manually to select the option - was just wondering if one key stroke could be used rather than ALT & key.(as an alternative)

    thanks for your inputs - sounds like I need to leave as is.

    regards

    Jon

Posting Permissions

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