which optionbutton is on

K

Keyur

I have 3 groups of optionbutton and an 'Ok' commandbutton. When i pres
'Ok' how do I get the captions of the 3 optionbuttons (one in eac
group), which are true.

Thanks for any help
 
G

Greg Wilson

This assumes that the option button groups are contained
inside frames. I don't think it's necessary to run
separate loops for each group but, at least for
illustrative purposes, here's my rendition:

Private Sub OKButton_Click()
Dim Ctl As Control, OB As Control
For Each Ctl In Me.Controls
If TypeOf Ctl Is msForms.Frame Then
For Each OB In Ctl.Controls
If OB Then MsgBox OB.Caption
Next
End If
Next
End Sub

Regards,
Greg
 
Top