In both the check box's AfterUpdate event procedure put code like this:
If Me.[YourCheckBox] Then
Me.[Spouse].Visible = True
Me.[NumberOfChildren].Visible = True
Else
Me.[Spouse].Visible = False
Me.[NumberOfChildren].Visible = False
Me.[Spouse] = Null
Me.[NumberOfChildren] = Null
End If
In the form's Current event procedure put:
If Me.[YourCheckBox] Then
Me.[Spouse].Visible = True
Me.[NumberOfChildren].Visible = True
Else
Me.[Spouse].Visible = False
Me.[NumberOfChildren].Visible = False
End If
In the first case the code also sets the values of the two controls to
Null.
This is in case any data has inadvertently been entered in those controls
prior to the check box being unchecked. Otherwise those values would
still
be present in the underlying fields, even though not seen on the form, and
could cause incorrect results when querying the database. In the second
case
this isn't necessary as the code there is merely to reflect the current
value
of the marital status field.
Note that this only works satisfactorily in single form view. In a
continuous form the two controls would be shown/hidden in all rows
depending
on the values in the currently selected row.
Ken Sheridan
Stafford, England
Khalil handal said:
A field in a table about marial status, Yes / No field
Is shown on a form as a check box.
If the check box for this field is checked (answer is yes), I want the
other
two field (name of spouse and number of males and female children) to be
shown on the form so that the user can fill in the requested info.
how can this be done?