R
rrm
How do you filter on 2 or more fields on a form? I have a form that uses
unbound combo box to select a stock number and a pair of unbound text boxes
that get a date range to further filter the selected stock number records.
That is for a given stock number show me the records that fall within this
date range.
I used the after update event for each, combo box and text box, but it will
either do the stock or date range, but not together. ( I tested each by
commenting out the other event code.)
Here is the code I use on the after update events on the 2 inputs. I think
I need some sort of "and" clause that ties the 2 fields to be filtered
together in the same filter statement but can't figure out where to put it.
Private Sub cbofindrecwhobotit_AfterUpdate()
' Find the record(s) that matches the control.
DoCmd.ApplyFilter , "Prod_Code = '" &
DblApp(Me.cbofindrecwhobotit.Value) & "'"
Me.FilterOn = True
End Sub
Private Sub txtwhobotenddat_AfterUpdate()
If txtwhobotstartdat.Value = "" Then
Me.Filter = "FULFILL_DT <= date()"
Else
Me.Filter = "FULFILL_DT between " & _
"(#" & Me.txtwhobotstartdat.Value & "#) " & _
"AND (#" & Me.txtwhobotenddat.Value & "#)"
End If
Me.FilterOn = True
Thank you for the help.
unbound combo box to select a stock number and a pair of unbound text boxes
that get a date range to further filter the selected stock number records.
That is for a given stock number show me the records that fall within this
date range.
I used the after update event for each, combo box and text box, but it will
either do the stock or date range, but not together. ( I tested each by
commenting out the other event code.)
Here is the code I use on the after update events on the 2 inputs. I think
I need some sort of "and" clause that ties the 2 fields to be filtered
together in the same filter statement but can't figure out where to put it.
Private Sub cbofindrecwhobotit_AfterUpdate()
' Find the record(s) that matches the control.
DoCmd.ApplyFilter , "Prod_Code = '" &
DblApp(Me.cbofindrecwhobotit.Value) & "'"
Me.FilterOn = True
End Sub
Private Sub txtwhobotenddat_AfterUpdate()
If txtwhobotstartdat.Value = "" Then
Me.Filter = "FULFILL_DT <= date()"
Else
Me.Filter = "FULFILL_DT between " & _
"(#" & Me.txtwhobotstartdat.Value & "#) " & _
"AND (#" & Me.txtwhobotenddat.Value & "#)"
End If
Me.FilterOn = True
Thank you for the help.