ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dynamically enable combo box if check box is checked (https://www.excelbanter.com/excel-programming/391717-dynamically-enable-combo-box-if-check-box-checked.html)

MAWII

Dynamically enable combo box if check box is checked
 
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

Susan

Dynamically enable combo box if check box is checked
 
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




MAWII

Dynamically enable combo box if check box is checked
 
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





Susan

Dynamically enable combo box if check box is checked
 
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 -




Steve the large[_2_]

Dynamically enable combo box if check box is checked
 
try
private sub checkbox4_click()
combobox6.enabled=checkbox4
end sub


"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





MAWII

Dynamically enable combo box if check box is checked
 
Nevermind--I figured it out.

Thanks!

"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





Steve the large[_2_]

Dynamically enable combo box if check box is checked
 
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 -





MAWII

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 -






All times are GMT +1. The time now is 01:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com