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 filters
Private Sub Search_Gauge_AFTERUPDATE()
Dim strfilter As String
On Error GoTo ErrHandler
If Me.Search_Gauge.Text <> "" Then
strfilter = "[Gauge Number] = '" & Me.Search_Gauge.Text & "'"
Me.Filter = strfilter
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
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 filters
Private Sub Search_Gauge_AFTERUPDATE()
Dim strfilter As String
On Error GoTo ErrHandler
If Me.Search_Gauge.Text <> "" Then
strfilter = "[Gauge Number] = '" & Me.Search_Gauge.Text & "'"
Me.Filter = strfilter
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