Grouping buttons

%3CLINGO-SUB%20id%3D%22lingo-sub-2199456%22%20slang%3D%22en-US%22%3EGrouping%20buttons%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2199456%22%20slang%3D%22en-US%22%3EHi%2C%20I%20have%20a%20form%20containing%2025%20command%20buttons%20divided%20into%205%20groups.%20I%20want%20them%20to%20behave%20like%20a%20radio%20button%2C%20that%20is%2C%20when%20I%20click%20a%20button%20in%20group%20%22a%22%20it%20will%20be%20red%20and%20all%20other%204%20button%20of%20the%20group%20remain%20blue%20(for%20example).%20Till%20now%20I%20used%20a%20function%20to%20set%20all%20buttons%20first%3A%3CBR%20%2F%3EFunction%20groupA()%3CBR%20%2F%3EB1.quickstyle%3D1%3CBR%20%2F%3EB2.quickstyle%3D1%3CBR%20%2F%3EB3.quickstyle%3D1%3CBR%20%2F%3EB4.quickstyle%3D1%3CBR%20%2F%3EB5.quickstyle%3D1%3CBR%20%2F%3EEnd%20function%3CBR%20%2F%3E%3CBR%20%2F%3EThen%20in%20every%20button%20click%20event%20I%20change%20its%20color%3A%3CBR%20%2F%3ESub%20B1_click()%3CBR%20%2F%3EgroupA%3CBR%20%2F%3EB1.quickstyle%3D8%3CBR%20%2F%3EEnd%20sub%3CBR%20%2F%3E%3CBR%20%2F%3EIs%20there%20a%20better%20way%3F%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2199456%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3E2016%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAccess%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor
Hi, I have a form containing 25 command buttons divided into 5 groups. I want them to behave like a radio button, that is, when I click a button in group "a" it will be red and all other 4 button of the group remain blue (for example). Till now I used a function to set all buttons first:
Function groupA()
B1.quickstyle=1
B2.quickstyle=1
B3.quickstyle=1
B4.quickstyle=1
B5.quickstyle=1
End function

Then in every button click event I change its color:
Sub B1_click()
groupA
B1.quickstyle=8
End sub

Is there a better way?
3 Replies

@Yassirmosawi 

What you want is a set of Option Groups, five in all. Each of these Option Groups will contain 5 of your buttons.

optiongroup.jpg

Thanks, that's what I need. Can I make the quickstyle of the selected button (toggle button) change when it is selected (clicked)?
I'm not sure how much control you have over the appearance of radio buttons. Perhaps try it out and see if the default behavior is sufficient.