Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have an optionbutton in a frame along with a variety of controls. I would
like to enable = True when the Option Button = True and visa versa. The code below works, but only for TextBoxes. Can this code work for all controls? Private Sub OptionButton13_Click() Dim ctrl As Control For Each ctrl In Me.Frame2.controls If TypeOf ctrl Is MsForms.TextBox Then ctrl.Enabled = OptionButton13.Value End If Next End Sub Thanks, Ryan |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
you're close.......... try this, i think the logic is right. check
the option button value FIRST, then loop through your controls. =========================== Private Sub OptionButton13_Click() Dim ctrl As Control if optionbutton13.value = true then For Each ctrl In Me.Frame2.controls If TypeOf ctrl Is MsForms.TextBox Then ctrl.Enabled = true End If Next end if End Sub ====================== (someone may have a better idea) susan On Jun 19, 8:41*am, RyanH wrote: I have an optionbutton in a frame along with a variety of controls. *I would like to enable = True when the Option Button = True and visa versa. *The code below works, but only for TextBoxes. *Can this code work for all controls? Private Sub OptionButton13_Click() Dim ctrl As Control For Each ctrl In Me.Frame2.controls * * If TypeOf ctrl Is MsForms.TextBox Then * * * * *ctrl.Enabled = OptionButton13.Value * * End If Next End Sub Thanks, Ryan |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need this loop to work for ALL controls. I have 2 other option buttons, 3
checkboxes, 4 comboboxes, 12 labels all in a frame. I want the enable value for all these controls to equal optionbutton13.Value. Is this possible? Thanks, Ryan "Susan" wrote: you're close.......... try this, i think the logic is right. check the option button value FIRST, then loop through your controls. =========================== Private Sub OptionButton13_Click() Dim ctrl As Control if optionbutton13.value = true then For Each ctrl In Me.Frame2.controls If TypeOf ctrl Is MsForms.TextBox Then ctrl.Enabled = true End If Next end if End Sub ====================== (someone may have a better idea) susan On Jun 19, 8:41 am, RyanH wrote: I have an optionbutton in a frame along with a variety of controls. I would like to enable = True when the Option Button = True and visa versa. The code below works, but only for TextBoxes. Can this code work for all controls? Private Sub OptionButton13_Click() Dim ctrl As Control For Each ctrl In Me.Frame2.controls If TypeOf ctrl Is MsForms.TextBox Then ctrl.Enabled = OptionButton13.Value End If Next End Sub Thanks, Ryan |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
i think you'll have to specify each type of control.
If TypeOf ctrl Is MsForms.combobox Then ctrl.enabled = true end if If TypeOf ctrl Is MsForms.label Then etc If TypeOf ctrl Is MsForms.optionbutton Then etc If TypeOf ctrl Is MsForms.checkbox Then etc AFAIK you can't select all forms of controls without identifying them separately. but i could be wrong. susan On Jun 19, 10:00*am, RyanH wrote: I need this loop to work for ALL controls. *I have 2 other option buttons, 3 checkboxes, 4 comboboxes, 12 labels all in a frame. *I want the enable value for all these controls to equal optionbutton13.Value. *Is this possible? Thanks, Ryan "Susan" wrote: you're close.......... *try this, i think the logic is right. *check the option button value FIRST, then loop through your controls. =========================== Private Sub OptionButton13_Click() *Dim ctrl As Control if optionbutton13.value = true then * * * For Each ctrl In Me.Frame2.controls * * * * * *If TypeOf ctrl Is MsForms.TextBox Then * * * * * * * * * ctrl.Enabled = true * * * * * *End If * * *Next end if End Sub ====================== (someone may have a better idea) susan On Jun 19, 8:41 am, RyanH wrote: I have an optionbutton in a frame along with a variety of controls. *I would like to enable = True when the Option Button = True and visa versa. *The code below works, but only for TextBoxes. *Can this code work for all controls? Private Sub OptionButton13_Click() Dim ctrl As Control For Each ctrl In Me.Frame2.controls * * If TypeOf ctrl Is MsForms.TextBox Then * * * * *ctrl.Enabled = OptionButton13.Value * * End If Next End Sub Thanks, Ryan- Hide quoted text - - Show quoted text - |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I was trying to avoid that, but I guess it will work. I currently have all
the controls as a collection, but I was just hoping for a more simple was of coding it. Thanks for the help, Ryan "Susan" wrote: i think you'll have to specify each type of control. If TypeOf ctrl Is MsForms.combobox Then ctrl.enabled = true end if If TypeOf ctrl Is MsForms.label Then etc If TypeOf ctrl Is MsForms.optionbutton Then etc If TypeOf ctrl Is MsForms.checkbox Then etc AFAIK you can't select all forms of controls without identifying them separately. but i could be wrong. susan On Jun 19, 10:00 am, RyanH wrote: I need this loop to work for ALL controls. I have 2 other option buttons, 3 checkboxes, 4 comboboxes, 12 labels all in a frame. I want the enable value for all these controls to equal optionbutton13.Value. Is this possible? Thanks, Ryan "Susan" wrote: you're close.......... try this, i think the logic is right. check the option button value FIRST, then loop through your controls. =========================== Private Sub OptionButton13_Click() Dim ctrl As Control if optionbutton13.value = true then For Each ctrl In Me.Frame2.controls If TypeOf ctrl Is MsForms.TextBox Then ctrl.Enabled = true End If Next end if End Sub ====================== (someone may have a better idea) susan On Jun 19, 8:41 am, RyanH wrote: I have an optionbutton in a frame along with a variety of controls. I would like to enable = True when the Option Button = True and visa versa. The code below works, but only for TextBoxes. Can this code work for all controls? Private Sub OptionButton13_Click() Dim ctrl As Control For Each ctrl In Me.Frame2.controls If TypeOf ctrl Is MsForms.TextBox Then ctrl.Enabled = OptionButton13.Value End If Next End Sub Thanks, Ryan- Hide quoted text - - Show quoted text - |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
i've got 2 other ideas that might help.........
#1 - why not make the entire frame visible or not visible based on that optionbutton13? that would take care of all those pesky individual controls. unless, of course, optionbutton13 is INSIDE the frame already....... #2 - why not give all those controls a group name - then you won't have to loop thru each control as a type, just as a group name. sorry i wasn't of more assistance. try also searching the newsgroup for control collection & maybe something else will come up. susan On Jun 19, 10:25*am, RyanH wrote: I was trying to avoid that, but I guess it will work. *I currently have all the controls as a collection, but I was just hoping for a more simple was of coding it. Thanks for the help, Ryan "Susan" wrote: i think you'll have to specify each type of control. If TypeOf ctrl Is MsForms.combobox Then * * *ctrl.enabled = true end if If TypeOf ctrl Is MsForms.label Then etc If TypeOf ctrl Is MsForms.optionbutton Then etc If TypeOf ctrl Is MsForms.checkbox Then etc AFAIK you can't select all forms of controls without identifying them separately. but i could be wrong. susan On Jun 19, 10:00 am, RyanH wrote: I need this loop to work for ALL controls. *I have 2 other option buttons, 3 checkboxes, 4 comboboxes, 12 labels all in a frame. *I want the enable value for all these controls to equal optionbutton13.Value. *Is this possible? Thanks, Ryan "Susan" wrote: you're close.......... *try this, i think the logic is right. *check the option button value FIRST, then loop through your controls. =========================== Private Sub OptionButton13_Click() *Dim ctrl As Control if optionbutton13.value = true then * * * For Each ctrl In Me.Frame2.controls * * * * * *If TypeOf ctrl Is MsForms.TextBox Then * * * * * * * * * ctrl.Enabled = true * * * * * *End If * * *Next end if End Sub ====================== (someone may have a better idea) susan On Jun 19, 8:41 am, RyanH wrote: I have an optionbutton in a frame along with a variety of controls. *I would like to enable = True when the Option Button = True and visa versa. *The code below works, but only for TextBoxes. *Can this code work for all controls? Private Sub OptionButton13_Click() Dim ctrl As Control For Each ctrl In Me.Frame2.controls * * If TypeOf ctrl Is MsForms.TextBox Then * * * * *ctrl.Enabled = OptionButton13.Value * * End If Next End Sub Thanks, Ryan- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You could also assign each control a tag value and then loop through all
controls. Dim ctrl As Control For Each ctrl In Me.Controls If ctrl.Tag = "EnableDisableMe" Then ... End If Next -- Tim Zych www.higherdata.com Compare data in worksheets and find differences with Workbook Compare A free, powerful, flexible Excel utility "RyanH" wrote in message ... I have an optionbutton in a frame along with a variety of controls. I would like to enable = True when the Option Button = True and visa versa. The code below works, but only for TextBoxes. Can this code work for all controls? Private Sub OptionButton13_Click() Dim ctrl As Control For Each ctrl In Me.Frame2.controls If TypeOf ctrl Is MsForms.TextBox Then ctrl.Enabled = OptionButton13.Value End If Next End Sub Thanks, Ryan |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Did you see my reply to your other post? It explains the problem and offers
a solution. Rick "RyanH" wrote in message ... I was trying to avoid that, but I guess it will work. I currently have all the controls as a collection, but I was just hoping for a more simple was of coding it. Thanks for the help, Ryan "Susan" wrote: i think you'll have to specify each type of control. If TypeOf ctrl Is MsForms.combobox Then ctrl.enabled = true end if If TypeOf ctrl Is MsForms.label Then etc If TypeOf ctrl Is MsForms.optionbutton Then etc If TypeOf ctrl Is MsForms.checkbox Then etc AFAIK you can't select all forms of controls without identifying them separately. but i could be wrong. susan On Jun 19, 10:00 am, RyanH wrote: I need this loop to work for ALL controls. I have 2 other option buttons, 3 checkboxes, 4 comboboxes, 12 labels all in a frame. I want the enable value for all these controls to equal optionbutton13.Value. Is this possible? Thanks, Ryan "Susan" wrote: you're close.......... try this, i think the logic is right. check the option button value FIRST, then loop through your controls. =========================== Private Sub OptionButton13_Click() Dim ctrl As Control if optionbutton13.value = true then For Each ctrl In Me.Frame2.controls If TypeOf ctrl Is MsForms.TextBox Then ctrl.Enabled = true End If Next end if End Sub ====================== (someone may have a better idea) susan On Jun 19, 8:41 am, RyanH wrote: I have an optionbutton in a frame along with a variety of controls. I would like to enable = True when the Option Button = True and visa versa. The code below works, but only for TextBoxes. Can this code work for all controls? Private Sub OptionButton13_Click() Dim ctrl As Control For Each ctrl In Me.Frame2.controls If TypeOf ctrl Is MsForms.TextBox Then ctrl.Enabled = OptionButton13.Value End If Next End Sub Thanks, Ryan- Hide quoted text - - Show quoted text - |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
yes i did, thanks again.
"Rick Rothstein (MVP - VB)" wrote: Did you see my reply to your other post? It explains the problem and offers a solution. Rick "RyanH" wrote in message ... I was trying to avoid that, but I guess it will work. I currently have all the controls as a collection, but I was just hoping for a more simple was of coding it. Thanks for the help, Ryan "Susan" wrote: i think you'll have to specify each type of control. If TypeOf ctrl Is MsForms.combobox Then ctrl.enabled = true end if If TypeOf ctrl Is MsForms.label Then etc If TypeOf ctrl Is MsForms.optionbutton Then etc If TypeOf ctrl Is MsForms.checkbox Then etc AFAIK you can't select all forms of controls without identifying them separately. but i could be wrong. susan On Jun 19, 10:00 am, RyanH wrote: I need this loop to work for ALL controls. I have 2 other option buttons, 3 checkboxes, 4 comboboxes, 12 labels all in a frame. I want the enable value for all these controls to equal optionbutton13.Value. Is this possible? Thanks, Ryan "Susan" wrote: you're close.......... try this, i think the logic is right. check the option button value FIRST, then loop through your controls. =========================== Private Sub OptionButton13_Click() Dim ctrl As Control if optionbutton13.value = true then For Each ctrl In Me.Frame2.controls If TypeOf ctrl Is MsForms.TextBox Then ctrl.Enabled = true End If Next end if End Sub ====================== (someone may have a better idea) susan On Jun 19, 8:41 am, RyanH wrote: I have an optionbutton in a frame along with a variety of controls. I would like to enable = True when the Option Button = True and visa versa. The code below works, but only for TextBoxes. Can this code work for all controls? Private Sub OptionButton13_Click() Dim ctrl As Control For Each ctrl In Me.Frame2.controls If TypeOf ctrl Is MsForms.TextBox Then ctrl.Enabled = OptionButton13.Value End If Next End Sub Thanks, Ryan- Hide quoted text - - Show quoted text - |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Error saying Control object does not have Enable property. | Excel Programming | |||
MultiPage: How to enable controls in Frame on Page | Excel Programming | |||
ddm enable/disable: Object doesn't support this property, my a** it doesn't | Excel Discussion (Misc queries) | |||
How get a row number of the controls(sample:optionbutton) | Excel Programming | |||
Enable and disable worksheet controls? | Excel Programming |