Results 1 to 5 of 5
  1. #1
    wvgour is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2015
    Posts
    3

    Multiple filters

    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!

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    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.

  3. #3
    wvgour is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2015
    Posts
    3
    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.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    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.

  5. #5
    wvgour is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2015
    Posts
    3
    Thanks so much! Its very useful!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Combining multiple toggle button filters
    By jasdem in forum Access
    Replies: 4
    Last Post: 09-18-2013, 10:29 AM
  2. Multiple Tables, Multiple Filters + Search
    By michael.legge@rbc.com in forum Access
    Replies: 1
    Last Post: 05-09-2013, 03:15 PM
  3. Multiple filters on a continuous form
    By Ray67 in forum Forms
    Replies: 3
    Last Post: 01-26-2013, 10:57 PM
  4. Report based on multiple filters
    By Johnny12 in forum Reports
    Replies: 1
    Last Post: 12-20-2012, 02:57 PM
  5. Apply Multiple filters
    By spitfire122 in forum Access
    Replies: 2
    Last Post: 07-01-2011, 10:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums