which optionbutton is on

  • Thread starter Thread starter Keyur
  • Start date Start date
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top