Qn: Checkbox Enable??

M

Michael Vaughan

Hello Everyone,

I have an checkbox option in my userform. How do I get it to blank or GRAY
out a TextBox area when the box is checked?? I saw a sample of how to
UNBLANK a textbox with the enable feature, but I need the opposite. What is
the opposite of enable?

a..
1.. Insert the following statement as the body of the new chkMonth_Click
procedure:
b.. txtMonth.Enabled = chkMonth.Value
c.. This statement will enable the text box whenever the check box is
selected, and disable the text box whenever the check box is cleared.
 
T

Tom Ogilvy

Enable is either true or false. The opposite of enabled = True is enabled =
False

you item b seems to do that already.

If you want it to operate opposite of the checkbox status then

txtMonth.Enabled = not chkMonth.Value
 
M

Michael Vaughan

Hi Tom,

Well, I put in the "txtMonth.Enabled = not chkMonth.Value" and the chkMonth
Box does NOT gray out when I check the box. Am I doing something wrong?? I
want an input box of txtMonth to gray out when I check the checkbox
chkMonth.

Thanks for all your help... mv
 
T

Tom Ogilvy

Private Sub CheckBox1_Click()
TextBox1.Enabled = Not CheckBox1.Value
End Sub

worked fine for me. There was no visible change to the textbox, but I
couldn't enter the textbox and enter a value when the checkbox was checked.

Are you using ActiveX controls or controls from the forms toolbar?


If activeX,
you can get some visual feedback with

Private Sub CheckBox1_Click()
TextBox1.Enabled = Not CheckBox1.Value
If CheckBox1.Value Then
TextBox1.SpecialEffect = fmSpecialEffectFlat
Else
TextBox1.SpecialEffect = fmSpecialEffectSunken
End If
End Sub

or you can set the backcolor to gray.
 
Top