PDA

View Full Version : Using option button properties



bujaman
10-09-2007, 10:07 PM
I am trying to get the code to hook together the caption property values for the various combo boxes selected and display the string of text in a cell. I have gotten it to get the first optionbutton caption value and put it where I want it (Thanks to xld's help), but I have multiple groups of optionbuttons and can't figure out how to get it to read the subsequent optionbuttons. I have attached the file so you can see it. Thanks for your help.

p45cal
10-10-2007, 09:11 AM
The following code is only an adaptation of a snippet of your own without the 'Exit For' line to allow it to run through ALL the option buttons on the form. I've not taken the time to look into this in any depth:
summat = ""
For Each ctl In Me.Controls
If TypeName(ctl) = "OptionButton" Then
If ctl.Value Then summat = summat & "|" & ctl.Caption
End If
Next ctlAfter this has run, 'summat' contains the likes of
"|Wells Fargo|Transfer|Checking"
I know it may not be in the right order vis-a-vis the user form, but you can further manipulate the text to your heart's content.

bujaman
10-10-2007, 11:07 AM
Thanks for that code, I got it to work, but I can't rearrange the order of how it pulls the Caption value, any tips on how to get it to be in this order: Transfer|Wells Fargo|Checking? Thanks again.

p45cal
10-10-2007, 12:42 PM
but you can further manipulate the text to your heart's content tack this snippet on:
summatelse = Split(summat, "|")
summat = summatelse(1) & "|" & summatelse(3) & "|" & summatelse(2)
The order is determined by the
For Each ctl In Me.Controls
line, which probably goes through them in the order they were added to the form.

bujaman
10-10-2007, 01:19 PM
Where should I put that code? I can't get it to work. Thanks for your help, I really appreciate it.

p45cal
10-10-2007, 01:30 PM
straight after the snippet in message #2

Oops, I assumed left to right as on the form, so change
summat = summatelse(1) & "|" & summatelse(3) & "|" & summatelse(2)
to
summat = summatelse(2) & "|" & summatelse(1) & "|" & summatelse(3)

bujaman
10-10-2007, 01:56 PM
Thanks for your help, it is working great.