PC Review


Reply
Thread Tools Rate Thread

Accessing groups of option buttons

 
 
Brotherwarren
Guest
Posts: n/a
 
      17th Feb 2008
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




 
Reply With Quote
 
 
 
 
Gary Keramidas
Guest
Posts: n/a
 
      17th Feb 2008
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
--


Gary


"Brotherwarren" <(E-Mail Removed)> wrote in message
news:2773fcd9-6f20-4ac2-9265-(E-Mail Removed)...
> 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
>
>
>
>



 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      17th Feb 2008
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


"Brotherwarren" wrote:

> 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
>
>
>
>
>

 
Reply With Quote
 
Brotherwarren
Guest
Posts: n/a
 
      17th Feb 2008
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

?

 
Reply With Quote
 
Brotherwarren
Guest
Posts: n/a
 
      17th Feb 2008
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

?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form with Option buttons - in groups Pepper Microsoft Word New Users 4 2nd Aug 2008 06:42 PM
Groups in Option buttons Greg B Microsoft Excel Programming 15 24th Jan 2008 06:09 PM
Two Groups of Option Buttons on Worksheet Jim May Microsoft Excel Misc 0 24th Jun 2006 09:34 PM
Option Buttons - groups =?Utf-8?B?Q2lhcmE=?= Microsoft Excel Misc 4 18th May 2005 05:41 PM
Command Buttons in Option Groups Tony Ford Microsoft Access Form Coding 16 26th Dec 2003 02:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:25 PM.