Open field based on checkbox

bluedigital

Registered User.
Local time
Today, 11:00
Joined
Nov 21, 2007
Messages
20
How do I have a field open for entry ONLY if a checkbox elsewhere on the formed is checked?
 
In the Property box of YourTextBox set Enabled to No.

Code:
Private Sub YourCheckBox_AfterUpdate()
 If YourCheckBox = -1 Then
  YourTextBox.Enabled = True
 Else
  Me.YourTextBox = ""
  YourTextBox.Enabled = False
 End If
End Sub

Private Sub Form_Current()
 If YourCheckBox = -1 Then
  YourTextBox.Enabled = True
 Else
  YourTextBox.Enabled = False
 End If
End Sub

If the user changes their mind and unchecks the box, the line Me.YourTextBox = "" deletes any value that may have been entered while the checkbox was checked. The checkbox nees to be bound to the underlying table.

Linq
 
hey buddy - I tried this code and for some reason it doesn't work. No change takes place to the text field when the checkbox is checked or unchecked. Incidentally, why do you have Me. in front of some of the field names, but not others?
 
hey buddy - I tried this code and for some reason it doesn't work. No change takes place to the text field when the checkbox is checked or unchecked. Incidentally, why do you have Me. in front of some of the field names, but not others?
 

Users who are viewing this thread

Back
Top Bottom