I’m trying to use a check-box to show/hide several input fields on a form. The names of the objects are:
- Check-box: CustomerCheckBox
- Input 1 field: customer_first_name
- Input 2 field: customer_last_name
- Input 3 field: customer_phone
According to my Google searching, I have the proper code and I’ve tried entering it into the check-box’s events After Update and On Click, and I’ve also tried adding the code to the form’s On Current event. Here is the code I’ve used in all 3 places (it’s the same code repeated):
Code:
Private Sub CustomerCheckBox_AfterUpdate()
Me.customer_first_name.Visible = (Me.CustomerCheckBox = True)
Me.customer_last_name.Visible = (Me.CustomerCheckBox = True)
Me.customer_phone.Visible = (Me.CustomerCheckBox = True)
End Sub
Code:
Private Sub CustomerCheckBox_Click()
Me.customer_first_name.Visible = (Me.CustomerCheckBox = True)
Me.customer_last_name.Visible = (Me.CustomerCheckBox = True)
Me.customer_phone.Visible = (Me.CustomerCheckBox = True)
End Sub
Code:
Private Sub Form_Current()
Me.customer_first_name.Visible = (Me.CustomerCheckBox = True)
Me.customer_last_name.Visible = (Me.CustomerCheckBox = True)
Me.customer_phone.Visible = (Me.CustomerCheckBox = True)
End Sub
Strange thing is, this code worked just fine when I created a brand new blank database and tried using a check-box to show/hide a label on a form.
Code:
Private Sub Check1_Click()
Me.Label0.Visible = (Me.Check1)
End Sub
Any ideas why it’s not working in my populated database/form?