I have a main form - frmMain
I have a subform - frmSub
I am populating two fields on frmMain from fields on frmSub.
The code that is nearly working is this:
Private Sub cmdUpdate_Click()
Dim Name1 As String
Dim Name2 As String
Dim Children As String
Name1 = DLookup("Individual_Name", "tblIndividual", "Individual_Type = 'Adult1' AND Family_ID = " & [Family_ID])
Name2 = Nz(DLookup("Individual_Name", "tblIndividual", "Individual_Type = 'Adult2' AND Family_ID = " & [Family_ID]))
Children = Nz(DLookup("Individual_Name", "tblIndividual", "Individual_Type = 'Child' AND Family_ID = " & [Family_ID]))
If Name2 = "" Then
Family_Names.SetFocus
Family_Names.Text = Name1
Else: Family_Names = Name1 & " & " & Name2
End If
Family_Children.SetFocus
Family_Children.Text = Children
End Sub
My problem is that I can have more than one Name with the Individual_Type "Child". The above code only gets the name of the first child. I need to get all children's names and concatenate them in a field on frmMain.
Any ideas please?
I have a subform - frmSub
I am populating two fields on frmMain from fields on frmSub.
The code that is nearly working is this:
Private Sub cmdUpdate_Click()
Dim Name1 As String
Dim Name2 As String
Dim Children As String
Name1 = DLookup("Individual_Name", "tblIndividual", "Individual_Type = 'Adult1' AND Family_ID = " & [Family_ID])
Name2 = Nz(DLookup("Individual_Name", "tblIndividual", "Individual_Type = 'Adult2' AND Family_ID = " & [Family_ID]))
Children = Nz(DLookup("Individual_Name", "tblIndividual", "Individual_Type = 'Child' AND Family_ID = " & [Family_ID]))
If Name2 = "" Then
Family_Names.SetFocus
Family_Names.Text = Name1
Else: Family_Names = Name1 & " & " & Name2
End If
Family_Children.SetFocus
Family_Children.Text = Children
End Sub
My problem is that I can have more than one Name with the Individual_Type "Child". The above code only gets the name of the first child. I need to get all children's names and concatenate them in a field on frmMain.
Any ideas please?