Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Nov 2002
    Location
    London, Gtr London, England
    Posts
    496
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Dear Loungers,

    how can I find out if a filter has been applied ot data - I want to remove it if that is the case before applying a new filter.

    thanks liz

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    If you are talking about data in a form, you can test the value of Me.Filter.

    But you don't need to remove a filter to set a new one.

    You are also need to be aware of the Me.FilterOn value, which is true or false. If me.FilterOn = false, then the form will not apply the filter.
    Regards
    John



  3. #3
    4 Star Lounger
    Join Date
    Nov 2002
    Location
    London, Gtr London, England
    Posts
    496
    Thanks
    8
    Thanked 0 Times in 0 Posts
    John,

    So, to be clear, does your reply mean that if I have applied a filter, and therefore have a subset of the data, a new filter will apply to the entire dataset and not the subset?

    Does the FilterOn property get set when ever a filter has been applied no matter where or how it is applied? For example: I can specify a filter in the Filter property of a form where I can also specify FilterOnLoad. I can also apply a filter using a macro or VBA and I can apply an ad-hoc filter using the context menu from a form: do all of these examples cause the FilterOn property to be set to True?

    • If me.FilterOn = false, then the form will not apply the filter.
      It's either too late or too early in the day.... I don't I understand this... if FilterOn is False a filter has not been applied to the data, so, which filter do you mean will not be applied? I can surely test if FilterOn is False and if it is the apply a specified filter?


    If I RemoveAllFilters and none exist I think an error is set, how do I test for this specific failure - so as to ignore it? I could of course test for FilterOn and only Remove if the result is true, but there must also be a specific error if RemoveAllFilters finds none a) what is it; and, related to this, b) where do I find a refernce of for these errors I can't find it in the listed trappable errors

    Finally, if I use RemoveAllFilters is this the same as setting Form.Filter ="" (or Null)?

    thank you.......................... liz

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    Quote Originally Posted by lizat View Post
    So, to be clear, does your reply mean that if I have applied a filter, and therefore have a subset of the data, a new filter will apply to the entire dataset and not the subset?
    Yes assuming the subset was created by applying a filter, rather than basing the form on a query that had criteria.
    A form has a filter property, and when you change it, you replace the previous filter with the new one.

    Does the FilterOn property get set when ever a filter has been applied no matter where or how it is applied? For example: I can specify a filter in the Filter property of a form where I can also specify Filteronload. I can also apply a filter using a macro or VBA and I can apply an ad-hoc filter using the context menu from a form: do all of these examples cause the FilterOn property to be set to True?

    • It's either too late or too early in the day.... I don't I understand this... if FilterOn is False a filter has not been applied to the data, so, which filter do you mean will not be applied? I can surely test if FilterOn is False and if it is the apply a specified filter?
    If you apply a filter using the Context Menu, then the FilterOn property will be automatically set. But if you apply it via code, it is not automatically set.
    So if I wanted to set this filter via code, I would write.

    Code:
    Me.filter= "[Animal]='cat'"
    Me.FilterOn=true
    If I used the first line without the second, the form would have a filter, but it would not be active, and so the data would not be fitlered by the filter.
    I don't know about Macros.

    If I RemoveAllFilters and none exist I think an error is set, how do I test for this specific failure - so as to ignore it? I could of course test for FilterOn and only Remove if the result is true, but there must also be a specific error if RemoveAllFilters finds none a) what is it; and, related to this, b) where do I find a refernce of for these errors I can't find it in the listed trappable errors

    Finally, if I use RemoveAllFilters is this the same as setting Form.Filter ="" (or Null)?
    Sorry I have no idea about Macros, and even less about the changes made in 2007, so I can't answer these questions.
    I can't even find RemoveAllFilters..Is it a macro command? I can't find it in 2010, which is where I am at the moment.
    Regards
    John



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •