Hi there!
I've buttons on a form
with a macro (ApplyFilter) assigned to guery fields.
It works fine,
but each new filter cancel previous, and works separately.
How can I apply two or more filters together?
Maybe VBA code is required?
Thanks!
Hi there!
I've buttons on a form
with a macro (ApplyFilter) assigned to guery fields.
It works fine,
but each new filter cancel previous, and works separately.
How can I apply two or more filters together?
Maybe VBA code is required?
Thanks!
You have to always combine the fields required to form a filter criteria. For ex. If you are looking for Customer named X, the filter will be [CustomerName]=X. Within the filtered results if you wish to search you have to add the filter criteria to the earlier one. for ex. looking for orders where X has ordered more than 50. The criteria will be [CustomerName]=X AND [OrderQuantity]>50. Never used Macros, VBA seems easier for me.
Thanks a lot!
I exported macros to VBA.
It looks like
First button:
Private Sub Command1_Click()
DoCmd.ApplyFilter "Filter1", "[MyQuery]![Checkbox1]=Yes", ""
End Sub
Second button:
Private Sub Command2_Click()
DoCmd.ApplyFilter "Filter2", "[MyQuery]![Checkbox2]=Yes", ""
End Sub
Third button:
Private Sub Command3_Click()
DoCmd.ApplyFilter "Filter3", "[MyQuery]![Checkbox3]=Yes", ""
End Sub
It works well, but still one by one.
How can each next filter be added to previous filters by cklicking button?
I'm sorry for this kind of questions,
but I'm in the very beginning of studying VBA,
and will really appreciate Your help.
Have one button to trigger the filter.
Build one filter criteria statement with conditional code.
Review: http://www.allenbrowne.com/ser-62.html
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Thanks so much! Its very useful!