L
Lau via AccessMonster.com
My main form is based on tbl_household_info which stores contact information
and subform is based on tbl_family_member which stores name, gender,
birthdate, etc. On the subform, I have a field called relationship that can
be any of these values:
Head of HH
Husband
Wife
Son
Daughter
What I would like to happen is that one of the family members must be set to
Head of HH before letting the user go to another household. In other words,
when pressing the backward or forward navigation button of the main form, it
needs to check to make sure Head of HH is selected for current family. So
far, I have tried the codes below, but they do not work. How can I accomplish
this task? Thanks.
*** AA is the code for Head of HH
Private Sub Form_Current()
If Me!house_num <> Null Then
If DLookup("[household_id]", "tbl_family_member", "[household_id] = " &
Me!sbf_family!household_id & " AND Me!sbf_family!relationship_id = 'AA'")
Then
'Do nothing
Else
'if no household is chosen, prompt to select one
MsgBox ("You must select a family member to be a Head of Household."),
vbOKOnly
Cancel = True
End If
End If
End Sub
and subform is based on tbl_family_member which stores name, gender,
birthdate, etc. On the subform, I have a field called relationship that can
be any of these values:
Head of HH
Husband
Wife
Son
Daughter
What I would like to happen is that one of the family members must be set to
Head of HH before letting the user go to another household. In other words,
when pressing the backward or forward navigation button of the main form, it
needs to check to make sure Head of HH is selected for current family. So
far, I have tried the codes below, but they do not work. How can I accomplish
this task? Thanks.
*** AA is the code for Head of HH
Private Sub Form_Current()
If Me!house_num <> Null Then
If DLookup("[household_id]", "tbl_family_member", "[household_id] = " &
Me!sbf_family!household_id & " AND Me!sbf_family!relationship_id = 'AA'")
Then
'Do nothing
Else
'if no household is chosen, prompt to select one
MsgBox ("You must select a family member to be a Head of Household."),
vbOKOnly
Cancel = True
End If
End If
End Sub