Accessing groups of option buttons

B

Brotherwarren

Hi folks,

Thanks for taking time to read this and for any advice you offer!

I have a userform with 27 rows of controls.

Each row contains a label control, the value of which is assigned
during the userforms initiate sub.

Next to each label there are 6 option buttons. I have grouped each
label and its option buttons with a frame.

At the moment I am cycling through all of the controls to find which
option button has been selected from each group, as follows:

Private Sub btnRunTrawl_Click()
Dim Ctr As Control

For Each Ctr In
UFSetUpDataTrawl.Controls
If TypeName(Ctr) =
"OptionButton" Then .......


Is there an easier way, for instance can I access each group of
controls separately?


Thanks again for any help you can offer.

Brotherwarren
 
G

Gary Keramidas

i do something very similar. but when i enter a frame, i reset the values of the
optionbuttons in the other frames to false with something like this:

Private Sub Frame1_Enter()
For Each cntrl In UserForm13.Frame2.Controls
If cntrl.Value = True Then
cntrl.Value = False
End If
Next
end sub
 
J

Joel

The userform has controls which includes buttons and frames. The frames have
controls which only include the buttons in the frame. So first find each of
the frames and ten look for the controls in each of the frames like the code
below.


Sub test()

For Each cntl In UserForm1.Controls
If Left(cntl.Name, 5) = "Frame" Then
For Each itm In cntl.Controls
MsgBox (itm.Name)
Next itm

End If

Next cntl

End Sub
 
B

Brotherwarren

Excellent work!

Thanks Joel.


One more thing, is there a benefit to using:

If Left(cntl.Name, 5) = "Frame" Then
For Each itm In cntl.Controls

instead of:

if typename(cntl) = "Frame" then

?
 
B

Brotherwarren

Excellent work!

Thanks Joel.


One more thing, is there a benefit to using:

If Left(cntl.Name, 5) = "Frame" Then
For Each itm In cntl.Controls

instead of:

if typename(cntl) = "Frame" then

?
 

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

Top