I have the following code in my form.
It is a cumulative search but I'm really struggling to filter by a specific date.
My date field is [SelectedPeriod]
When the form opens the fields t6 and t7 are defaulted to two dates that will ensure that all of the the data is filtered ie. t6 -01/01/2000 and t7 = 01/01/2020
I use AfterUpdate to call this code.
I want to be able to incorporate t6 and t7 into my existing filter.
I just can't seem to get it to work.
Any pointers ?
Or (seeing as how there are defaulted dates in both t6 and t7) have a between filter in both of the AfterUpdate of t6 and t7
Thanks for your time in advance.
It is a cumulative search but I'm really struggling to filter by a specific date.
My date field is [SelectedPeriod]
When the form opens the fields t6 and t7 are defaulted to two dates that will ensure that all of the the data is filtered ie. t6 -01/01/2000 and t7 = 01/01/2020
I use AfterUpdate to call this code.
I want to be able to incorporate t6 and t7 into my existing filter.
I just can't seem to get it to work.
Any pointers ?
Code:
Private Sub subChangeFilter()
If Nz(Me.t1, "") <> "" Then
strfilter = strfilter & "ID like '*" & Replace(Me.t1, "'", "''") & "*' and "
End If
If Nz(Me.t2, "") <> "" Then
strfilter = strfilter & "Client like '*" & Replace(Me.t2, "'", "''") & "*' and "
End If
If Nz(Me.t3, "") <> "" Then
strfilter = strfilter & "Campaign like '*" & Replace(Me.t3, "'", "''") & "*' and "
End If
If Nz(Me.t4, "") <> "" Then
strfilter = strfilter & "Last_Name like '*" & Replace(Me.t4, "'", "''") & "*' and "
End If
If Nz(Me.t5, "") <> "" Then
strfilter = strfilter & "First_Name like '*" & Replace(Me.t5, "'", "''") & "*' and "
End If
If Nz(Me.t6, "") <> "" Then
'THIS IS WHERE I WANT TO FILTER BY DATE T6 BEING THE START DATE ie. SelectedPeriod >= T6
End If
If Nz(Me.t7, "") <> "" Then
'THIS IS WHERE I WANT TO FILTER BY DATE T7 BEING THE END DATE ie SelectedPeriod<=T7
End If
If strfilter <> "" Then
strfilter = Left(strfilter, Len(strfilter) - 4)
End If
Debug.Print strfilter
Me.Filter = strfilter
Me.FilterOn = True
End Sub
Or (seeing as how there are defaulted dates in both t6 and t7) have a between filter in both of the AfterUpdate of t6 and t7
Thanks for your time in advance.