Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Option buttons in two levels groups

Hi,
I have about 50 options buttons that are grouped in 8 main groups accessible
through 8 main level option buttons. Once a main level option button is
selected, a sub level group appears (the other ones become invisible) for the
user to select a sub level option. There is a default option on both levels
so that there is always a selection in both levels. I need to find the sub
level option button that is selected to continue the process.
I came upon this code from Rick Rothstein (commented by Dave Peterson) and
adapted it to suit my case but I always get options from the first subgroup.
The last one selected remains the one that will come out. I cannot get any of
the others even though they are visible and selected. What could be the
problem?
Here is the code:
Dim ctrOb As Control
Dim ctrObSelected As msforms.OptionButton
' On Error Resume Next
For Each ctrOb In Controls
If TypeOf ctrOb Is msforms.OptionButton Then
If ctrOb.GroupName < "grpCompte" And _
ctrOb.GroupName < "grpDrpTypeTransac" And _
ctrOb.GroupName < "grpDrpTransfert" And _
ctrOb.GroupName < "grpTypeTransac" Then
If ctrOb.Value = True Then
Set ctrObSelected = ctrOb
Exit For
End If
End If
End If
Next
If Err.Number 0 Then
MsgBox "No OptionButton selected"
Else
MsgBox "ctrObSelected.Name = " & ctrObSelected.Name & _
vbCrLf & "ctrObSelected.Caption = " & ctrObSelected.Caption
End If
Thank you.
--
Jac Tremblay
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Option buttons in two levels groups

Hi, it's me...
I found a simple solution. In a separate procedure where I hide all the
subgroups before I display the one selected, I added some code to deselect
all options. It goes like that and works fine.
Dim ctrOb As Control
For Each ctrOb In Controls
If TypeOf ctrOb Is msforms.OptionButton Then
If ctrOb.GroupName < "grpCompte" Then
If ctrOb.Value = True Then ctrOb.Value = False
End If
End If
Next
I was inspired by Rick and Dave. Thanks to them.
I thought I posted this for the benefit of the community.
Good night to everyone.

--
Jac Tremblay


"Jac Tremblay" wrote:

Hi,
I have about 50 options buttons that are grouped in 8 main groups accessible
through 8 main level option buttons. Once a main level option button is
selected, a sub level group appears (the other ones become invisible) for the
user to select a sub level option. There is a default option on both levels
so that there is always a selection in both levels. I need to find the sub
level option button that is selected to continue the process.
I came upon this code from Rick Rothstein (commented by Dave Peterson) and
adapted it to suit my case but I always get options from the first subgroup.
The last one selected remains the one that will come out. I cannot get any of
the others even though they are visible and selected. What could be the
problem?
Here is the code:
Dim ctrOb As Control
Dim ctrObSelected As msforms.OptionButton
' On Error Resume Next
For Each ctrOb In Controls
If TypeOf ctrOb Is msforms.OptionButton Then
If ctrOb.GroupName < "grpCompte" And _
ctrOb.GroupName < "grpDrpTypeTransac" And _
ctrOb.GroupName < "grpDrpTransfert" And _
ctrOb.GroupName < "grpTypeTransac" Then
If ctrOb.Value = True Then
Set ctrObSelected = ctrOb
Exit For
End If
End If
End If
Next
If Err.Number 0 Then
MsgBox "No OptionButton selected"
Else
MsgBox "ctrObSelected.Name = " & ctrObSelected.Name & _
vbCrLf & "ctrObSelected.Caption = " & ctrObSelected.Caption
End If
Thank you.
--
Jac Tremblay

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing groups of option buttons Brotherwarren Excel Programming 4 February 17th 08 09:31 PM
Groups in Option buttons Greg B[_12_] Excel Programming 15 January 24th 08 07:09 PM
with multiple option buttons on my form how do I isolate groups sabrina Excel Worksheet Functions 4 September 17th 07 10:06 PM
Two Groups of Option Buttons on Worksheet Jim May Excel Discussion (Misc queries) 0 June 24th 06 09:34 PM
Option Buttons - groups Ciara Excel Discussion (Misc queries) 4 May 18th 05 05:41 PM


All times are GMT +1. The time now is 11:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"