I have created a checkbox on a form and when it is "checked" a textbox is enabled and when it is not the textbox is not enabled. My problem is that when I go to create a new record I want the textbox to be disabled. Right now, when I go to a new record the checkbox is not checked, but the text box is enabled. I've been messing with this thing for hours and cant figure it out.
This is what I have now:
Private Sub Mailing_Sent_Click()
If Me.Mailing_Sent = 0 Then
Me.Text54.Enabled = False
Me.Text54.Enabled = True
I set the default value of the checkbox (in the property window) to False so if the checkbox is Null on a new record you disable the textbox. I also used the NZ() function around the value of the checkbox in the code to ensure it always returns False if the checkbox has no value.
I could have done this:
If mycheckboxvalue=True then
I saved a few steps and just set the Enabled property of the text box to the True or False value of the checkbox:
The checkbox is bound to the customer table so each record can have its own separate checkbox setting. If you don't bind it to a table, then the checkbox will stay the same no matter what record the form is moved to.
You can of course use programming behind the form to set the value of the checkbox at the form load event to True or False, and you can also change the checkbox value along the way using programming.