S
Simeon Cheeseman
hi there i have the following code to filter my query, and none of the
filters seem to be working. as the recorset initially gives one or two
records back and then after filtering it never changes.
Dim date_id1 As Integer
Dim date_id2 As Integer
Dim date_id3 As Integer
Dim childm As Integer
Dim child1 As Integer
Dim child2 As Integer
Dim child3 As Integer
Dim qry1 As String
Dim qry1filter1 As String
Dim qry1filter2 As String
Dim qry1filter3 As String
Dim qry2filter1 As String
Dim qry2filter2 As String
Dim qry2filter3 As String
Dim where1 As String
Dim where2 As String
Dim where3 As String
where1 = "((child_id) = " & child1 & ")"
where2 = "((child_id) = " & child2 & ")"
where3 = "((child_id) = " & child3 & ")"
childm = id_str
child1 = date_id1
child2 = date_id2
child3 = date_id3
qry1filter1 = "((([child_1]) = " & child1 & ") OR (([child_2]) = " &
child1 & "))"
qry1filter2 = "((([child_1]) = " & child2 & ") OR (([child_2]) = " &
child2 & "))"
qry1filter3 = "((([child_1]) = " & child3 & ") OR (([child_2]) = " &
child3 & "))"
qry2filter1 = "(([child_id_1]) = " & child1 & ") OR (([child_id_2]) = "
& child1 & ")"
qry2filter2 = "(([child_id_1]) = " & child2 & ") OR (([child_id_2]) = "
& child2 & ")"
qry2filter3 = "(([child_id_1]) = " & child3 & ") OR (([child_id_2]) = "
& child3 & ")"
qry1 = "SELECT child_1, child_2 " & _
"FROM tbl_risks " & _
"WHERE (((child_1) = " & childm & ")) OR (((child_2) = " &
childm & "));"
Me.RecordSource = qry1
Me.Requery
Set rst = Me.RecordsetClone
If child1 <> 0 Then
rst.Filter = qry1filter1
If rst.EOF = True Then
rst.Filter = adFilterNone
Else: DoCmd.OpenForm errorform, , , where1
End If
End If
Set rst = Me.RecordsetClone
If child2 <> 0 Then
rst.Filter = qry1filter2
If rst.EOF = True Then
rst.Filter = adFilterNone
Else: DoCmd.OpenForm errorform, , , where2
End If
End If
Set rst = Me.RecordsetClone
If child3 <> 0 Then
rst.Filter = qry1filter3
If rst.EOF = True Then
rst.Filter = adFilterNone
Else: DoCmd.OpenForm errorform, , , where3
End If
End If
rst.Filter = adFilterNone
any help would be apprecited
filters seem to be working. as the recorset initially gives one or two
records back and then after filtering it never changes.
Dim date_id1 As Integer
Dim date_id2 As Integer
Dim date_id3 As Integer
Dim childm As Integer
Dim child1 As Integer
Dim child2 As Integer
Dim child3 As Integer
Dim qry1 As String
Dim qry1filter1 As String
Dim qry1filter2 As String
Dim qry1filter3 As String
Dim qry2filter1 As String
Dim qry2filter2 As String
Dim qry2filter3 As String
Dim where1 As String
Dim where2 As String
Dim where3 As String
where1 = "((child_id) = " & child1 & ")"
where2 = "((child_id) = " & child2 & ")"
where3 = "((child_id) = " & child3 & ")"
childm = id_str
child1 = date_id1
child2 = date_id2
child3 = date_id3
qry1filter1 = "((([child_1]) = " & child1 & ") OR (([child_2]) = " &
child1 & "))"
qry1filter2 = "((([child_1]) = " & child2 & ") OR (([child_2]) = " &
child2 & "))"
qry1filter3 = "((([child_1]) = " & child3 & ") OR (([child_2]) = " &
child3 & "))"
qry2filter1 = "(([child_id_1]) = " & child1 & ") OR (([child_id_2]) = "
& child1 & ")"
qry2filter2 = "(([child_id_1]) = " & child2 & ") OR (([child_id_2]) = "
& child2 & ")"
qry2filter3 = "(([child_id_1]) = " & child3 & ") OR (([child_id_2]) = "
& child3 & ")"
qry1 = "SELECT child_1, child_2 " & _
"FROM tbl_risks " & _
"WHERE (((child_1) = " & childm & ")) OR (((child_2) = " &
childm & "));"
Me.RecordSource = qry1
Me.Requery
Set rst = Me.RecordsetClone
If child1 <> 0 Then
rst.Filter = qry1filter1
If rst.EOF = True Then
rst.Filter = adFilterNone
Else: DoCmd.OpenForm errorform, , , where1
End If
End If
Set rst = Me.RecordsetClone
If child2 <> 0 Then
rst.Filter = qry1filter2
If rst.EOF = True Then
rst.Filter = adFilterNone
Else: DoCmd.OpenForm errorform, , , where2
End If
End If
Set rst = Me.RecordsetClone
If child3 <> 0 Then
rst.Filter = qry1filter3
If rst.EOF = True Then
rst.Filter = adFilterNone
Else: DoCmd.OpenForm errorform, , , where3
End If
End If
rst.Filter = adFilterNone
any help would be apprecited