Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

two filters that work fine indepentently but override eachothers results

Status
Not open for further replies.

Kekins1

Technical User
Jul 16, 2015
6
GB
I have two filters one called "Search_Gauge" and the other called " "Search_Date", both of these are on a form.
When i tpe in a Gauge number it displays all of the records relating to that gauge, then I want to use the search_date filter to further filter the results. However when I use the search_date filter it searches for all records with that date in but I only want records of that gauge number on that date.
here is the code for the search_date filter
Private Sub Search_Gauge_AFTERUPDATE()
Dim strfilter1 As String
On Error GoTo ErrHandler
If Me.Search_Gauge.Text <> "" Then
strfilter1 = "[Gauge Number] = '" & Me.Search_Gauge.Text & "'"
Me.Filter = strfilter1
Me.FilterOn = True
Else
Me.Filter = ""
Me.FilterOn = False
End If
With Me.Search_Gauge
.SetFocus
.SelStart = Len(Me.Search_Gauge.Text)
End With
Exit Sub
ErrHandler:
MsgBox Err.Description, vbExclamation
End Sub
Private Sub Search_Date_AFTERUPDATE()
Dim strfilter As String
On Error GoTo ErrHandler
If Me.Search_Date.Text <> "" Then
strfilter = "[Date Calibrated] Like '*" & Me.Search_Date.Text & "*'"
Me.Filter = strfilter
Me.FilterOn = True



Else
Me.Filter = ""
Me.FilterOn = False

End If
If strfilter1 <> "" Then
strfilter = strfilter & " AND [Gauge Number]='" & Me.Search_Gauge.Text & "'"
Me.Filter = strfilter1
Me.FilterOn = True
End If

With Me.Search_Date
.SetFocus
.SelStart = Len(Me.Search_Date.Text)
End With

Exit Sub
ErrHandler:
MsgBox Err.Description, vbExclamation

End Sub
Thanks
Kris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top