how to enable/disable textbox based on checkbox value

lamha

Registered User.
Local time
Today, 12:57
Joined
Jun 21, 2000
Messages
76
I have 44 checkboxes, each has a textbox next to it. What I want is when the user selects a checkbox, the textbox next to it will be enabled. Also, when the user unselect a checkbox, the textbox next to it will be disabled and any value entered is cleared.

Another way is whenever the user enters a value in a textbox, the checkbox associate with it is selected and vice versa.

I don't know which way is easier. Any help would be greatly appreciated.
 
Hello:
The below code does what you ask:
Private Sub Check3_AfterUpdate()
If txtText1.Enabled = True Then
txtText1.Enabled = False
Else
txtText1.Enabled = True
End If
End Sub

When you open your form you will have to test for the check box values and implement the same type of code:
'
To clear the text box you would use the following:
'
txtText1 = ""
Regards
Mark
 
Thanks for your reply but I think there must be a better way to do this in one event instead of doing it 44 AfterUpdate events for 44 controls.
 
Im not sure whether VBA allows it but have you thought of using a FOR loop! Im not sure however if you are able to send parameters in a fuction call tho!
 

Users who are viewing this thread

Back
Top Bottom