• Can’t set form filter to empty string (2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Can’t set form filter to empty string (2000)

    Author
    Topic
    #401233

    I use the code below to set a form’s Filter property. It works fine until the variable strF contains an empty string. When this happens the line Me.Filter = strF seems to be ignored and I am always left with whatever the previous filter was. Me.Filter doesn’t accept Null. Is there some other way of emptying it? I know I could turn the filter off but this seems to a sledgehammer to crack a nut.

    Me.Filter = strF
    Me.FilterOn = True
    Me.txtFilter = Me.Filter

    Ian

    Viewing 0 reply threads
    Author
    Replies
    • #788951

      You cannot set the Filter property to Null, but you *can* set it to the empty string “”. This automatically sets FilterOn to False.

      If you set FilterOn to False by itself, the Filter property will remain intact, but inactive. You can reactivate it by setting FilterOn to True again.

      • #789312

        I know that’s the theory but I find that it sometimes doesn’t work and wondered if there was a known bug.

        • #789343

          Setting Me.Filter = “” is supposed to be “the” way to remove a filter. I haven’t experienced problems with it, but then I don’t use Access 2000.

          I don’t see why setting Me.FilterOn = False is a “sledgehammer approach” – you can use either that or DoCmd.ShowAllRecords to turn off the filter. As I wrote before, this will NOT clear the Filter property, only deactivate it.

        • #789344

          Setting Me.Filter = “” is supposed to be “the” way to remove a filter. I haven’t experienced problems with it, but then I don’t use Access 2000.

          I don’t see why setting Me.FilterOn = False is a “sledgehammer approach” – you can use either that or DoCmd.ShowAllRecords to turn off the filter. As I wrote before, this will NOT clear the Filter property, only deactivate it.

        • #789419

          You can’t *change* a filter midstream without turning the FilterOn property off first, if that’s what you’re trying to do.

        • #789420

          You can’t *change* a filter midstream without turning the FilterOn property off first, if that’s what you’re trying to do.

          • #789439

            Yes, that’s what I was doing. I didn’t realise there was a problem. Do you mean I have to do the following when changing a form’s filter?

            1) Create new filter string
            2) Set FilterOn to false
            3) Assign new filter string to Me.Filter
            4) Set FilterOn to True.

            I haven’t done this in the past because, up to the current problem, changing the Me.Filter property on the fly has always worked. If I follow the above approach, will I have to stop the form from refreshing until I have finished?

            Ian

            • #789857

              The nature of some of the properties changed between 97 and 2000. Properties that were variants became strongly typed as strings, and I believe that Filter was one of those. I haven’t been able to make 2000 change form filters on the fly without first turning off the filteron property and then changing the filter and turning filteron back on. Perhaps someone else has found a secret that I haven’t discovered.

            • #789858

              The nature of some of the properties changed between 97 and 2000. Properties that were variants became strongly typed as strings, and I believe that Filter was one of those. I haven’t been able to make 2000 change form filters on the fly without first turning off the filteron property and then changing the filter and turning filteron back on. Perhaps someone else has found a secret that I haven’t discovered.

          • #789440

            Yes, that’s what I was doing. I didn’t realise there was a problem. Do you mean I have to do the following when changing a form’s filter?

            1) Create new filter string
            2) Set FilterOn to false
            3) Assign new filter string to Me.Filter
            4) Set FilterOn to True.

            I haven’t done this in the past because, up to the current problem, changing the Me.Filter property on the fly has always worked. If I follow the above approach, will I have to stop the form from refreshing until I have finished?

            Ian

      • #789313

        I know that’s the theory but I find that it sometimes doesn’t work and wondered if there was a known bug.

    Viewing 0 reply threads
    Reply To: Can’t set form filter to empty string (2000)

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

    Your information: