how to disable textbox in the current field based on data?

  • Thread starter Thread starter alpha_male
  • Start date Start date
A

alpha_male

I have a form where, I would disable writing in data in one text field
if the value of other field is "true" check for respective record? Can
you send example how to do it.
 
You could do something like this in the form's On Current event:

If Me.chkMyCheckbox = True Then
Me.txtMyTextBox.Enabled = True
Else: Me.txtMyTextBox.Enabled = False
End If

Use the same code in the After Update event for the check box. Use Visible
instead of Enabled to hide the text box completely, and switch True and False
to suit your needs.

To add the code to the On Current event, in form design view double click
the little square at the top left of the form (where the rulers meet - it has
a small dark square inside it), click the Event tab, click On Current, click
the three dots that appear on the right, click Code Builder, OK, then add the
code at the cursor (substituting the names of your check box and text box).
Double click the check box to add code to it in the same way.
 
Back
Top