PDA

View Full Version : what is wrong with this code?



jeff06
07-05-2007, 11:46 AM
I have a checkbox and two textbox.
i will do this: when I check the chechbox (checboxturn) if it is enable, it will be disable, if it is originally disable, it will be enabled.

The followng code does not work this way. How can I fix this problem?
Thanks.

<code>Private Sub CheckBoxTurn_Click()
If CheckBoxTurn.Enabled = True Then
CheckBoxTurn.Enabled = False
TextBoxTurnStart.Enabled = True
TextBoxTurnEnd.Enabled = True
End If
If CheckBoxTurn.Enabled = False Then
CheckBoxTurn.Enabled = True
TextBoxTurnStart.Enabled = False
TextBoxTurnEnd.Enabled = False
End If

End Sub
[/CODE]

Ebrow
07-05-2007, 12:05 PM
Hi is this what you are looking for.

6144

Bob Phillips
07-05-2007, 12:13 PM
This is probably what you want



Private Sub CheckBoxTurn_Click()
With CheckBoxTurn
TextBoxTurnStart.Enabled = .Value
TextBoxTurnEnd.Enabled = .Value
End With
End Sub

Ebrow
07-05-2007, 12:28 PM
a wee bit more efficent than my example. Nice. I will use that method from now on.