Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default How to referance a GroupName


I have a frame containing three optionbuttons. I have set the groupname
in the properties inspector manaually to "TaxGroup".

How do i reference this ie get the value or a value of it. Could I use
the select case statement to then action on which optionbutton is true.

Select Case Controls("TaxGroup").Value

Case Is = 1

Case "OptionButton1": txtTax.Value = "Includes"
Case "OptionButton2": txtTax.Value = "Excludes"
Case "OptionButton3": txtTax.Value = "Non Taxable"
End Select

garry

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to referance a GroupName

There is not a "group" object as you seem to want to use.

Dim obtn as MSforms.OptionButton
Dim cntrl as Control
set obtn = nothing
for each cntrl in Userform1.Frame1.Controls
if typeof cntrl is MSforms.OptionButton then
if cntrl.groupname = "TaxGroup" then
if cntrl then
set obtn = cntrl
exit for
end if
end if
end if
Next
if not obtn is nothing then
Select Case obtn.Name
Case "OptionButton1": txtTax.Value = "Includes"
Case "OptionButton2": txtTax.Value = "Excludes"
Case "OptionButton3": txtTax.Value = "Non Taxable"
End Select

Else
msgbox "None Selected"
End if

you can take out the check for TaxGroup if those are the only option buttons
in the frame.
--
Regards,
Tom Ogilvy


"Garry" wrote in message
...

I have a frame containing three optionbuttons. I have set the groupname
in the properties inspector manaually to "TaxGroup".

How do i reference this ie get the value or a value of it. Could I use
the select case statement to then action on which optionbutton is true.

Select Case Controls("TaxGroup").Value

Case Is = 1

Case "OptionButton1": txtTax.Value = "Includes"
Case "OptionButton2": txtTax.Value = "Excludes"
Case "OptionButton3": txtTax.Value = "Non Taxable"
End Select

garry

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default How to referance a GroupName

Tom

Tx.

I had to change the last bit to get it to work, thats my fault.

If Not obtn Is Nothing Then
Select Case obtn.Name
Case "OptionButton1"
txtTax = "Includes"
Case "OptionButton2"
txtTax = "Excludes"
Case "OptionButton3"
txtTax = "Non Taxable"

End Select

I have two frames on the form and was wondering if I could combine them
in one loop statement. At the moment I have just duplicated the original
code and changed the variables.

Group name is "TypeGroup"
If Not obtn Is Nothing Then
Select Case obtn.Name
Case "OptionButton4"
txtType = "Fees"
Case "OptionButton5"
txtType = "Expenses"

End Select

garrygdc

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to referance a GroupName

Public Function GetButton(fr as MSForms.Frame, grpName as String)
Dim obtn as MSforms.OptionButton
Dim cntrl as Control
set obtn = nothing
for each cntrl in fr
if typeof cntrl is MSforms.OptionButton then
if lcase(cntrl.groupname) = lCase(grpName) then
if cntrl then
set obtn = cntrl
exit for
end if
end if
end if
Next
set GetButton = obtn
End Function

Private Sub CommandButton1_Click
Dim oBtn1 as MSForms.OptionButton
Dim oBtn2 as MSForms.OptionButton
set oBtn1 = GetButton(Userform1.Frame1, "TaxGroup")
set oBtn2 = GetButton(Userform1.Frame2, "TypeGroup")
If Not obtn1 Is Nothing Then
Select Case obtn1.Name
Case "OptionButton1"
txtTax = "Includes"
Case "OptionButton2"
txtTax = "Excludes"
Case "OptionButton3"
txtTax = "Non Taxable"
End Select
End if

If Not obtn2 Is Nothing Then
Select Case obtn2.Name
Case "OptionButton4"
txtType = "Fees"
Case "OptionButton5"
txtType = "Expenses"
End Select
End if

End Sub

Might be one approach.

--
Regards,
Tom Ogilvy


"Garry" wrote in message
...
Tom

Tx.

I had to change the last bit to get it to work, thats my fault.

If Not obtn Is Nothing Then
Select Case obtn.Name
Case "OptionButton1"
txtTax = "Includes"
Case "OptionButton2"
txtTax = "Excludes"
Case "OptionButton3"
txtTax = "Non Taxable"

End Select

I have two frames on the form and was wondering if I could combine them
in one loop statement. At the moment I have just duplicated the original
code and changed the variables.

Group name is "TypeGroup"
If Not obtn Is Nothing Then
Select Case obtn.Name
Case "OptionButton4"
txtType = "Fees"
Case "OptionButton5"
txtType = "Expenses"

End Select

garrygdc

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



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
ISFORMULA(Cell Referance) lessburgfred Excel Worksheet Functions 4 November 13th 09 05:14 PM
Help with a formula. Lookup? referance? Joe Excel Worksheet Functions 5 February 4th 07 02:06 AM
Circular Referance John Vickers Excel Discussion (Misc queries) 2 February 15th 06 08:56 AM
GroupName Paul Excel Programming 2 December 4th 03 11:33 AM
Cross Referance Nathan[_3_] Excel Programming 1 November 7th 03 06:56 AM


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

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

About Us

"It's about Microsoft Excel"