View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
MAWII MAWII is offline
external usenet poster
 
Posts: 18
Default Dynamically enable combo box if check box is checked

I used the following...

Private Sub checkbox1_click()

If checkbox1.Value = False Then
combobox1.Enabled = False
Else
combobox1.Enabled = True
End If

End Sub

Seemed a lot easier to me and I figured it out shortly after the request.
It does the trick. Thanks for the help!

Mark

"Steve the large" wrote:

checkbox4.value is boolean (true or false), when ".value" left off, checkbox4
defaults to it's value. I know, it's kind of terse, but it works.

The click event occurs whether the checkbox is click to be "on" or clicked
to be "off". This code just makes use of the checkbox property ".value".



"Susan" wrote:

hmmmm.
for that you'll need to add a boolean value, so the macro can tell if
it's being "checked" or "unchecked" - it only notices "clicked".

in your initialization sub, add

dim myBoolean as boolean

myBoolean=true


then in
private sub checkbox4_click()
if myboolean=true then
combobox6.enabled=true
myboolean=false
else
combobox6.enabled=false
myboolean=true
end if
end sub


1. so - userform opens - boolean value is true.
checkbox is checked the first time - combobox becomes enabled, boolean
value is set to false.

2. 2nd time checkbox is triggered, it runs thru the same private sub,
but this time the boolean value is NOT true, so it skips the 1st part
of the if statement. since boolean value is false, the 2nd part of
the if statement kicks in, dis-enabling the combobox & changing the
boolean back to true.

3. if it gets checked a 3rd time, it goes back to #1 above.

:)
susan


On Jun 20, 2:47 pm, MAWII wrote:
Thanks! That works great--how do I get it to disable the combobox if the
checkbox is unchecked again? Right now, the combobox enables when the
checkbox is checked, but stays enabled if the checkbox is clicked again...



"Susan" wrote:
in your userform_initialization sub, add

combobox6.enabled=false '<-- change to your combobox

then in your userform coding, you would add something like

private sub checkbox4_click() '<-- change to your checkbox
combobox6.enabled=true
end sub

so when checkbox4 is clicked (or "checked"), combobox6 automatically
becomes enabled.

hth!
susan

On Jun 20, 2:16 pm, MAWII wrote:
I have a userform with multiple combo boxes. I also have a check box as a
response to a question on the form. If checked, I would like the combo box
for the next question enabled. By default, I want the same combo box
disabled. How do I do this dynamically? Thanks!

Mark- Hide quoted text -

- Show quoted text -