Button Enabling based on check in checkbox

T

Todd Huttenstine

I have CheckBox1 and TextBox1 on a UserForm. The goal is
to only enable Textbox1 to be typed in only if checkbox1
has a check in it. I would like to achieve this by using
an IF THEN statement. All Responses are welcome.

Thank you in advance.

Todd Huttenstine
 
T

Tom Ogilvy

Todd chose:

Private Sub CheckBox1_Click()
If Checkbox1.Value = True Then
Textbox2.Enabled = True
Else
Textbox2.Enabled = False
End If
End Sub

in lieu of

Private Sub CheckBox1_Click()
Me.TextBox1.Enabled = CBool(Me.CheckBox1.Value)
End Sub
 
J

JON JON

Hello Todd,

Give this a try:

Private Sub UserForm_Initialize()
'This will set the default value
Me.CheckBox1.Value = False
Me.TextBox1.Enabled = False
End Sub

Private Sub CheckBox1_Click()
If Me.CheckBox1.Value = True Then
Me.TextBox1.Enabled = True
Else
Me.TextBox1.Enabled = False
End If
End Sub

Regards,

Jon-jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top