D
Deb H
I have a combo box on a main form that I am trying to use to filter records
in a related subform. The main form uses a table named Families and the
subform is based on a table named Children. Whenever I select a value from
the combo box to find a record in the subform it selects the wrong record.
There is a one to many relationship between the tables. I am using Access
2003.
Here is my code:
Private Sub Combo162_AfterUpdate()
Dim strSQL As String
If IsNull(Me.Combo162) Then
' If the combo is Null, use the whole table as the RecordSource.
Me.RecordSource = "Families"
Else
strSQL = "SELECT DISTINCTROW Families.* FROM Families " & _
"INNER JOIN Children ON " & _
"Families.ID = Children.ID " & _
"WHERE Children.ID = " & Me.Combo162 & ";"
Me.RecordSource = strSQL
End If
End Sub
I've looked at Allen Browne's tip from previous posts to troubleshoot this,
but I'm still missing something to effectively filter the correct record. Any
ideas?
in a related subform. The main form uses a table named Families and the
subform is based on a table named Children. Whenever I select a value from
the combo box to find a record in the subform it selects the wrong record.
There is a one to many relationship between the tables. I am using Access
2003.
Here is my code:
Private Sub Combo162_AfterUpdate()
Dim strSQL As String
If IsNull(Me.Combo162) Then
' If the combo is Null, use the whole table as the RecordSource.
Me.RecordSource = "Families"
Else
strSQL = "SELECT DISTINCTROW Families.* FROM Families " & _
"INNER JOIN Children ON " & _
"Families.ID = Children.ID " & _
"WHERE Children.ID = " & Me.Combo162 & ";"
Me.RecordSource = strSQL
End If
End Sub
I've looked at Allen Browne's tip from previous posts to troubleshoot this,
but I'm still missing something to effectively filter the correct record. Any
ideas?