Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Button Enabling based on Checkbox
I have CheckBox1 and TextBox1 on a UserForm. What is the
code that would enable entry into TextBox1 if CheckBox1 has a check in it? Thank you Todd Huttenstine |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Button Enabling based on Checkbox
Todd,
Try something like the following in the user form's code module: Private Sub CheckBox1_Click() Me.TextBox1.Enabled = CBool(Me.CheckBox1.Value) End Sub "Todd uttenstine" wrote in message ... I have CheckBox1 and TextBox1 on a UserForm. What is the code that would enable entry into TextBox1 if CheckBox1 has a check in it? Thank you Todd Huttenstine |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Button Enabling based on Checkbox
It still allows the user to click in the textbox if they
dont check the box first. Once they check the box and then remove the check, then the code works, but I need the code to work even if the user doesnt check the check box. -----Original Message----- Todd, Try something like the following in the user form's code module: Private Sub CheckBox1_Click() Me.TextBox1.Enabled = CBool(Me.CheckBox1.Value) End Sub "Todd uttenstine" wrote in message ... I have CheckBox1 and TextBox1 on a UserForm. What is the code that would enable entry into TextBox1 if CheckBox1 has a check in it? Thank you Todd Huttenstine . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Button Enabling based on Checkbox
Hi Chip:
Just out of curiosity, why the CBool? Regards, Vasant. "Chip Pearson" wrote in message ... Todd, Try something like the following in the user form's code module: Private Sub CheckBox1_Click() Me.TextBox1.Enabled = CBool(Me.CheckBox1.Value) End Sub "Todd uttenstine" wrote in message ... I have CheckBox1 and TextBox1 on a UserForm. What is the code that would enable entry into TextBox1 if CheckBox1 has a check in it? Thank you Todd Huttenstine |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Button Enabling based on Checkbox
I cannot get that method to work flawlessly. I think I
need an if then statement. -----Original Message----- I have CheckBox1 and TextBox1 on a UserForm. What is the code that would enable entry into TextBox1 if CheckBox1 has a check in it? Thank you Todd Huttenstine . |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Button Enabling based on Checkbox
Rule no 2: don't make it complicated.
At design time, set the enabled property of the textbox to false, and the value of the checkbox to unchecked. Then add this code to the click event of the checkbox. If Check1.Value = 1 Then Text1.Enabled = True Else Text1.Enabled = False End If "Todd uttenstine" wrote in message ... I have CheckBox1 and TextBox1 on a UserForm. What is the code that would enable entry into TextBox1 if CheckBox1 has a check in it? Thank you Todd Huttenstine |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Button Enabling based on Checkbox
That still does not work properly. It works before I
check it, but after I check it and then take the check out, I can still type in the box and its not supposed to do that because there is no check in the box. -----Original Message----- Rule no 2: don't make it complicated. At design time, set the enabled property of the textbox to false, and the value of the checkbox to unchecked. Then add this code to the click event of the checkbox. If Check1.Value = 1 Then Text1.Enabled = True Else Text1.Enabled = False End If "Todd uttenstine" wrote in message ... I have CheckBox1 and TextBox1 on a UserForm. What is the code that would enable entry into TextBox1 if CheckBox1 has a check in it? Thank you Todd Huttenstine . |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Button Enabling based on Checkbox
Got it! Changed the code to the following. All I had to
do was set the checkbox1.value to true instead of 1. Thanx. If Checkbox1.Value = True Then Textbox2.Enabled = True Else Textbox2.Enabled = False End If -----Original Message----- Rule no 2: don't make it complicated. At design time, set the enabled property of the textbox to false, and the value of the checkbox to unchecked. Then add this code to the click event of the checkbox. If Check1.Value = 1 Then Text1.Enabled = True Else Text1.Enabled = False End If "Todd uttenstine" wrote in message ... I have CheckBox1 and TextBox1 on a UserForm. What is the code that would enable entry into TextBox1 if CheckBox1 has a check in it? Thank you Todd Huttenstine . |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Button Enabling based on Checkbox
Chip's code works perfectly for me. Are you sure you're following it exactly
and have provided all the information? -- Vasant "Todd Huttenstine" wrote in message ... That still does not work properly. It works before I check it, but after I check it and then take the check out, I can still type in the box and its not supposed to do that because there is no check in the box. -----Original Message----- Rule no 2: don't make it complicated. At design time, set the enabled property of the textbox to false, and the value of the checkbox to unchecked. Then add this code to the click event of the checkbox. If Check1.Value = 1 Then Text1.Enabled = True Else Text1.Enabled = False End If "Todd uttenstine" wrote in message ... I have CheckBox1 and TextBox1 on a UserForm. What is the code that would enable entry into TextBox1 if CheckBox1 has a check in it? Thank you Todd Huttenstine . |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Button Enabling based on Checkbox
Yes It was working for me but it would not work before I
checked the check box. I am not sure why. I did get it working with the if then code. Thank you. -----Original Message----- Chip's code works perfectly for me. Are you sure you're following it exactly and have provided all the information? -- Vasant "Todd Huttenstine" wrote in message ... That still does not work properly. It works before I check it, but after I check it and then take the check out, I can still type in the box and its not supposed to do that because there is no check in the box. -----Original Message----- Rule no 2: don't make it complicated. At design time, set the enabled property of the textbox to false, and the value of the checkbox to unchecked. Then add this code to the click event of the checkbox. If Check1.Value = 1 Then Text1.Enabled = True Else Text1.Enabled = False End If "Todd uttenstine" wrote in message ... I have CheckBox1 and TextBox1 on a UserForm. What is the code that would enable entry into TextBox1 if CheckBox1 has a check in it? Thank you Todd Huttenstine . . |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Button Enabling based on Checkbox
Private Sub CheckBox1_Click() TextBox1.Enabled = CheckBox1.Value End Sub -----Original Message----- I cannot get that method to work flawlessly. I think I need an if then statement. -----Original Message----- I have CheckBox1 and TextBox1 on a UserForm. What is the code that would enable entry into TextBox1 if CheckBox1 has a check in it? Thank you Todd Huttenstine . . |
#12
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Button Enabling based on Checkbox
Just out of curiosity, why the CBool?
Force of habit. In VB6, the Value property of a CheckBox returns an Integer, not a Boolean. I like to do the conversion to boolean myself -- self-documenting code and all that. Just in case the TripleState property of the CheckBox is True, the better code would be as follows: Private Sub CheckBox1_Click() With Me.TextBox1 If IsNull(Me.CheckBox1.Value) Then .Enabled = False ' or True, as desired Else .Enabled = Me.CheckBox1.Value End If End With End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message ... Hi Chip: Just out of curiosity, why the CBool? Regards, Vasant. "Chip Pearson" wrote in message ... Todd, Try something like the following in the user form's code module: Private Sub CheckBox1_Click() Me.TextBox1.Enabled = CBool(Me.CheckBox1.Value) End Sub "Todd uttenstine" wrote in message ... I have CheckBox1 and TextBox1 on a UserForm. What is the code that would enable entry into TextBox1 if CheckBox1 has a check in it? Thank you Todd Huttenstine |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Checkbox and conditional formating | Excel Discussion (Misc queries) | |||
Enabling voting button | Excel Discussion (Misc queries) | |||
Shrinking Checkbox and Radio Button | Excel Discussion (Misc queries) | |||
using a checkbox for a conditional function | Excel Worksheet Functions | |||
Help with function to add percentage to cell based on checkbox. | Excel Worksheet Functions |