Make controls visible based on Checkbox value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a form which contains a subform. On the subform I have a
checkbox. Based on whether or not this is ticked, other controls on the
subform are either visible or not (I've used VB to code it - sample below).

If NewHire.Value = True Then
JobTitle.Visible = True
EmployeeID.Visible = False
Else
JobTitle.Visible = False
EmployeeID.Visible = True
End If

However, if I have more than one record on the subform, and I click any of
the checkboxes, this results in ALL the JobTitle and EmployeeID controls
being affected. How can I "bind" the specific checkbox to the related
JobTitle and EmployeeID controls?
 
ES said:
I have created a form which contains a subform. On the subform I have a
checkbox. Based on whether or not this is ticked, other controls on the
subform are either visible or not (I've used VB to code it - sample below).

If NewHire.Value = True Then
JobTitle.Visible = True
EmployeeID.Visible = False
Else
JobTitle.Visible = False
EmployeeID.Visible = True
End If

However, if I have more than one record on the subform, and I click any of
the checkboxes, this results in ALL the JobTitle and EmployeeID controls
being affected. How can I "bind" the specific checkbox to the related
JobTitle and EmployeeID controls?

There is no way of doing this directly. If you have at least Access 2000,
then you can do some conditional formatting (it's on the Format menu in the
form design view) but the Visible property is not one of the things you can
control. I suppose that you might be able to use conditional formatting to
change the foreground and background colours to be the same as the
background colour of the form, but if the controls have borders then they
will still be visible.
 
Back
Top