CharlieT302
Instructor
Hi Folks,
I would like to create a simple filter that works similar in concept to the "Advanced Filter" found in the Records menu.
Creating it on one field is fine, but I can't get it to work with two fields. I have two unbound objects in the form header: ID Search and ItemSearch.
My code (below) works fine with either of them, but not with both. I basically need an "And" statement in the criteria.
Here is what I have:
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Sales Form"
stLinkCriteria = "Val([empid])=" & Me![Id Search]
DoCmd.RunCommand acCmdApplyFilterSort
Exit_Filter_Month_Click:
Exit Sub
This works fine. Note, the Val statement is there because the "empid" field is a text field, that the unbound field; ID Search, stores the user's entry as a number.
However, if I add:
And "Val([ItemNumber])=" & Me![Item Search] to the criteria statement, I get a type mismatch error.
All I need is an "And" statment to be able to match both fields. This code is attached to a push button.
Any Ideas? This seems like it should be a simple matter.
Thanks
I would like to create a simple filter that works similar in concept to the "Advanced Filter" found in the Records menu.
Creating it on one field is fine, but I can't get it to work with two fields. I have two unbound objects in the form header: ID Search and ItemSearch.
My code (below) works fine with either of them, but not with both. I basically need an "And" statement in the criteria.
Here is what I have:
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Sales Form"
stLinkCriteria = "Val([empid])=" & Me![Id Search]
DoCmd.RunCommand acCmdApplyFilterSort
Exit_Filter_Month_Click:
Exit Sub
This works fine. Note, the Val statement is there because the "empid" field is a text field, that the unbound field; ID Search, stores the user's entry as a number.
However, if I add:
And "Val([ItemNumber])=" & Me![Item Search] to the criteria statement, I get a type mismatch error.
All I need is an "And" statment to be able to match both fields. This code is attached to a push button.
Any Ideas? This seems like it should be a simple matter.
Thanks