• Removing a filter

    Author
    Topic
    #466666

    I often provide a list form with the capacity to filter and sort, then a Print button that passes the current filter and sort order to a Report for printing the list.

    I attach a demo.

    The column headings act as Sort buttons, and you can filter by School. Once a filter is applied, a Clear Filter button becomes visible that will remove the filter with:

    Code:
    Me.Filteron=False
    Me.filter=""
    

    The Problem
    If I apply a Filter, then Clear it, then Sort, the filter that I have just removed reappears again when I go to the Report.
    Why?

    It seems that Access ignores the Me.Filter=”” line.

    I have a workaround for this, but I feel that I should not need it.
    (In the Print button code, I can test for me.filteron =true.)

    Viewing 1 reply thread
    Author
    Replies
    • #1209614

      I agree with you, John, that you should not need a workaround.
      What I found is that while changing the OrderBy value the old FilterBy value gets restored. Interestingly though, the FilterByOn value of False is retained during these steps. However, if you set the OrderByOn value to False before changing the OrderBy value then the FilterBy property is undisturbed. I think if you simply add the statement Me.OrderByOn = False to the beginning of your fnSort function then your report will display as you would like.

    • #1209767

      Thanks for that. You are absolutely correct that putting in Me.OrderByOn=False into the Sort function fixes things up. This seems about as bizarre as the original problem but is worth knowing.

      I use form filters a lot, but I came across a post somewhere else recently in which an Access MVP said that forms filters were notoriously “flaky”. (I can’t find it now)

    Viewing 1 reply thread
    Reply To: Removing a filter

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: