PDA

View Full Version : User form hotkeys



blackie42
11-18-2007, 01:54 PM
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

mikerickson
11-18-2007, 01:59 PM
Use OnKey to assign the key to a routine.

blackie42
11-18-2007, 02:30 PM
Hi,

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

thanks

mikerickson
11-18-2007, 02:58 PM
OptionButton1 sounds like a control.
The help system describes how to use OnKey with all the keys on a standard keyboard, including function keys.

blackie42
11-18-2007, 03:39 PM
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?

mikerickson
11-18-2007, 04:10 PM
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.

TonyJollans
11-18-2007, 04:51 PM
... might mess up the other text box inputs

Indeed! That's why key modifiers are used.

blackie42
11-19-2007, 05:17 AM
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

TonyJollans
11-19-2007, 11:12 AM
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.

blackie42
11-19-2007, 11:30 AM
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