Results 1 to 6 of 6
  1. #1
    ScubaBart is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Jul 2024
    Posts
    117

    Controlling multiple criteria filters

    Say I have a form that I opened with a certain filter (I tend to use the Where this = that format) and then I apply another filter to the content (usually in a continuous form).

    I then want to remove the 2nd filter but not the first filter that was applied when the form opened.

    I'm guessing I would have to explicitly reconfigure the 2nd filter to be all inclusive ? If I set the FilterOn property to false, it would remove all the filter criteria, even the conditions set when the form opened, right ?



    Just trying to get a grasp on this before I dive in head first and start making adjustments.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Setting FilterOn to False does just that. It doesn't affect the filter.
    Try it and see.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    In a brief test setting FilterOn to false removes the filter applied by opening the form with a wherecondition. I might pass the original filter in OpenArgs so you can go back to it as desired.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Quote Originally Posted by pbaldy View Post
    In a brief test setting FilterOn to false removes the filter applied by opening the form with a wherecondition. I might pass the original filter in OpenArgs so you can go back to it as desired.
    Wow, I never knew that.
    My apologies @ScubBart. I have literally just set a filter off and then back on and left the filter alone.
    However in my testing, after setting filteron to False, if I use Toggle Filter from the ribbon, the filter is set again.

    So I tested this from the command window and I get the filter still set?

    Code:
    docmd.OpenForm "frmPressure",,,"pressureID <30"
    forms!frmpressure.filteron = false
    ? forms!frmpressure.filter
    pressureID <30
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    The where parameter of openform is badly named as it just applies a filter. It just prioritises those records to display before you can use the form - the rest of the table/query will continue to load in the background.

    Five options:
    1: include a criteria to the query before opening the form
    2: use openargs to pass the criteria to the form and in the open event modify the recordsource to include the criteria
    3: in the form load event , capture the filter and use that instead of “” when the filter is to be cleared (won’t work if using the form filter features)
    4: similar to 1, use the equally poorly named filter parameter to specify a query where the criteria is specified
    5: put your form as a subform and use the linkchild/master properties to set the initial filter

    for very large datasets or complex queries I recommend using 1 or 2 for performance reasons and limit the amount of data brought through

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Quote Originally Posted by Welshgasman View Post
    Wow, I never knew that.
    My apologies @ScubBart. I have literally just set a filter off and then back on and left the filter alone.
    However in my testing, after setting filteron to False, if I use Toggle Filter from the ribbon, the filter is set again.

    So I tested this from the command window and I get the filter still set?

    Code:
    docmd.OpenForm "frmPressure",,,"pressureID <30"
    forms!frmpressure.filteron = false
    ? forms!frmpressure.filter
    pressureID <30
    Unless I misunderstood, the problem is that further filters get applied, so perhaps:

    pressureID <30 AND Blah = 123

    The problem is how to go back to

    pressureID <30

    Hence my suggestion of putting that in OpenArgs. That all said, I may have misunderstood and thus be all wet.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Controlling Multiple Option Compatibility
    By btappan in forum Access
    Replies: 2
    Last Post: 03-08-2021, 08:38 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. Replies: 12
    Last Post: 08-26-2012, 02:09 PM
  4. Controlling autonumber
    By Patience in forum Access
    Replies: 3
    Last Post: 06-22-2010, 04:11 AM
  5. Checkbox controlling text box
    By chuckduarte in forum Forms
    Replies: 0
    Last Post: 10-21-2008, 10:45 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