Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default 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
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
Checkbox and conditional formating sed Excel Discussion (Misc queries) 3 November 8th 08 09:56 PM
Enabling voting button kd Excel Discussion (Misc queries) 0 April 24th 08 09:36 AM
Shrinking Checkbox and Radio Button Dennis C BroadWare Excel Discussion (Misc queries) 0 November 10th 06 03:01 PM
using a checkbox for a conditional function Brac Excel Worksheet Functions 4 December 8th 05 06:12 PM
Help with function to add percentage to cell based on checkbox. foxgguy2005 Excel Worksheet Functions 3 June 1st 05 05:52 AM


All times are GMT +1. The time now is 04:48 AM.

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

About Us

"It's about Microsoft Excel"