+ Reply to Thread
Results 1 to 8 of 8

userform radio button group determination of selection?

  1. #1
    Registered User
    Join Date
    07-22-2005
    Location
    canada
    Posts
    73

    userform radio button group determination of selection?

    Hello,

    Ok, I have a userform, with a grouped set of 5 radio buttons.
    Is their a fast way of determining which of the 5 was selected, instead of
    having to do a _click determination of each radio selection itself.

    I have the the groupname to : Score1_RadioGroup


    Also, is their a way to indicate the choice of the group through arrow key
    selection?

    Currently, I have a textbox where a number will be entered, and then I
    would like the user to be able to tab to the group of radio buttons, and using
    an arrow key, to set the desired choice.
    The reason, is that it would allow for all key press commands to set all the
    options without having to use the mouse. Allows for much faster data entry.

    Thanks in advance,

    spyrule.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Spyrule,

    I am going to start with your last question about tabbing. Each control on a UserForm has 2 properties that control tabbing: the TabStop and the TabIndex. TabIndex controls which control will receive the Focus next when the tab key is used. Wether a control accepts the Focus depends on the state of TabStop. If TabStop is False the control won't take the Focus.

    The TabIndex starts at 0 abd increments by 1 for each control on the UserForm. When you change the TabIndex of a control, VBA automatically changes the other control's TabIndex values.

    Example of changin the Tab Order:

    1. In the VB Editor display your user form.
    2. Click on TextBox1 and look at the Properties Window.
    3. If it isn't visible, press tthe F4 key
    4. Select the TabIndex property (for this example will say it is 5)
    5. On the UserForm, Click on the first RadioButton in group.
    6. Read the TabIndex (for this example will say it is 11)
    7. To make this the next control to take the Focus when the Tab key is pressed, change this to 6.
    8. Repeat steps 5 to 8 for each RadioButton. Be sure to increment the value by 1. RadioButton2 = 7, RadioButton3 = 8, etc.


    Now for the second question. Determening which option button is set. Here is ta function that will return the name of the radio Button that is selected. You will need to change UserForm1 in the code if your UserForm name is different.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    07-22-2005
    Location
    canada
    Posts
    73

    thank you but...

    First,

    Thanks for the reply Leith, it's apreciated.

    following your message order, I understand how to use Tab index/Tab Stop
    features, more what I was referring to is how to make a grouped set of radio
    buttons "selectable" using arrow keys instead of a click or spacebar. Right
    now when I tab over, the first radio button is the next tab in sequence,
    however their seems to be no "highlight" of that radio button, until I press
    the spacebar. Also, it wont let me move the selection using arrow keys.
    This would be a very usefull control "feature" to have, but I have no idea
    how to implement it without adding hundreds of lines of code.

    Also as for the function that you gave me, that seems to work for all of the
    functions, but I'm not sure how to limit it to just that group of radio buttons,
    one set at a time.

    I attached a picture, to give you an idea of what I'm talking about.

    The first "checkbox" turns on/off that row of controls. If turned on, form
    those controls must be filled. If off, they may have data, but they will be
    ignored. Also if say, 2nd and 3rd checkbox is selected, you cannot turn off
    2nd without turning off 3rd first.
    Then when that row is active, the user will enter a number in score textbox,
    tab over to the radio option and "choose" one of the radio button, preferably
    using their arrow keys.

    hope this makes sense.

    spyrule.
    Attached Images Attached Images

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Spyrule,

    To get the feature you want takes some work. I will give you a couple of code examples of what needs to done, and we can go from there.

    To have an OptionButton respond to the Arrow Keys requires adding code to each OptionButton's KeyDown event procedure. This code example has OptionButton1 move over to OptionButton2 on the right and select it.

    Please Login or Register  to view this content.
    This example looks at OptionButton2. This OptionButton can go left, back to optionButton1, or to the right, OptionButton3. You would use this same format for OptionButtons2 - 4.

    Please Login or Register  to view this content.
    The last OptionButton on the right, OptionButton5...

    Please Login or Register  to view this content.
    This would have to be repeated for each of the groups you have, and the OptionButton names would need to changed to match what you are using.

    Sincerely,
    Leith Ross

  5. #5
    Registered User
    Join Date
    07-22-2005
    Location
    canada
    Posts
    73

    ok, so mouse it is! :)

    Thanks again,

    yeah thats way more code then I want to include in this project for purely a
    visual method. The user will have to be happy with using a mouse!

    I have 3 other forms with a total of 50 radio button controls EACH, and that
    makes MUCH too much code to have to repeat.

    Now I just have to get the radio button detection to work with the single
    button at the button.

    spyrule.

  6. #6
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,167

    Re: userform radio button group determination of selection?

    Thanks for this code:
    Please Login or Register  to view this content.
    Regards

    Rick
    Win10, Office 365

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,284

    Re: userform radio button group determination of selection?

    You can use a Select Case to determine which button is checked:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  8. #8
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,167

    Re: userform radio button group determination of selection?

    Quote Originally Posted by romperstomper View Post
    You can use a Select Case to determine which button is checked:
    Please Login or Register  to view this content.
    Thnak you

    Thats Enlgish for Thank You. :P

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1