Why Why Why Do Deleted Filters/OrderBys ReAppear

gray

Registered User.
Local time
Today, 22:42
Joined
Mar 19, 2007
Messages
578
Hi

I've been stuck on this issue for weeks... I've tried scheme after scheme, idea after idea....

Why, why, why, why do deleted Filters/OrderBys re-appear when I've deleted them using VB in Acc2007

In a mainform/subform setup I want to delete all user applied filters and orderbys on exit (using custom Exit button).

I manually cleared all the Filters and OrderBys in Design View

I used me.form.filter="" and me.subform_name.form.filter ="" and/or
me.form.filter=vbNullString and me.subform_name.form.filter =vbNullString

I used acSaveNo and acSaveYes variously in the Exit

I've tried the Runcommands to RemoveAllSorts, RemoveAllFilters

I now even edit the forms on exit with:-
Code:
    DoCmd.Close acForm, Me.Name
 
    DoCmd.OpenForm "Addrs_Dtls_Form", acDesign, , , , acHidden
    Forms![Addrs_Dtls_Form].Filter = ""
    Forms![Addrs_Dtls_Form].OrderBy = ""
    Forms![Addrs_Dtls_Form].FilterOn = False
    Forms![Addrs_Dtls_Form].OrderByOn = False
    DoCmd.Close acForm, "Addrs_Dtls_Form", acSaveYes
 
    DoCmd.OpenForm "Addrs_Dtls_SubForm", acDesign, , , , acHidden
    Forms![Addrs_Dtls_SubForm].Filter = ""
    Forms![Addrs_Dtls_SubForm].OrderBy = ""
    Forms![Addrs_Dtls_SubForm].FilterOn = False
    Forms![Addrs_Dtls_SubForm].OrderByOn = False
    DoCmd.Close acForm, "Addrs_Dtls_SubForm", acSaveYes
    DoCmd.SetWarnings True
And STILL the subform filters and orderbys persist!!

Why do the Access fairies keep putting them back and which magical chant do I use to stop them please??

Thanks
 
In situations like this I always assume that I screwed up the logic, until I can prove otherwise.

1. "Persist" means get applied?
2. You haven't shown the remainder of your interaction with filters: there is probably a logic trap in there somewhere

Have you tried to set a watch on your filters?

Update:

And Plan B would be to start shaving bits and pieces off, until you get a working skeleton that still fails, and then keep shaving until the problem is gone. Or the other way around: rebuild the thing bit by bit. Whichever is the easiest.
 
Last edited:
Hi

Thanks for replying... If I've screwed up the logic, it wouldn't be the first time!! :)

"By Persist" ... I've gone thru' many, many iterations but here's my latest.. I've added some screen shots to illustrate..

Filters_01.jpg - Kill all filters in design mode.. main
Filters_02.jpg - Kill all filters in design mode.. sub
Filters_03.jpg - Open form and use right-click to add a sort in subform (the ApplyFilter event also adds this to main form)
Filters_04.jpg - Exit the form and, on the way, edit both forms to kill filters and orderbys.
Filters_05.jpg - Open subform in design mode... and hey presto the old filters and orderbys are back from the dead... :)

I already have Perform Name Autocorrect unticked, incidentally.

cheers
 

Attachments

  • Filters_01.jpg
    Filters_01.jpg
    102.5 KB · Views: 89
  • Filters_02.jpg
    Filters_02.jpg
    99.2 KB · Views: 104
  • Filters_03.jpg
    Filters_03.jpg
    97.4 KB · Views: 96
  • Filters_04.jpg
    Filters_04.jpg
    98.7 KB · Views: 95
  • Filters_05.jpg
    Filters_05.jpg
    96.8 KB · Views: 97
Last edited:
I had a similar issue a few months ago, where filters kept reemerging. Unfortunately I don't recall how I solved it, because the problem disappeared after a major redesign: A query was being applied as filter in the db I inherited, and I couldn't kill it. Due to other considerations, I redesigned underlying record set to depend on the selections made, and then the problem disappeared by itself.

Have you tried to kill the filters in OnLoad?
 
Hi

Thank god it's not just me! I thought i was seeing things...

Yes, I check on the form_open to if any of the blighters are hanging around.... Initially, when I found them I cleared them with me.filter="" and me.orderby = "" ... but they then re-appeared as soon as a sort was applied!! arrghhh... so I took the exact same achidden edit code as that in my exit (which is not reliable as you have seen)... but when I call it in form_open the filters do get deleted! Whatttt! So why not just leave it at that?... To do the hidden edit, the form has to be closed... not gonna' impress any user with that one.. every time they open the form it closes itself....

I am stunned... thanks for looking at this..
 
My not be this issue, but I had something similar I delt with.

In Win Vista (and I assume Win 7) if your database is in "Program Files" and you make any changes, it'll save those changes in the application data folder. Then when you go back to your database, boom all your changes have been reverted.

There were some other weird issues with the db being in "Program Files" so I just moved the whole thing to a folder under the c:\ drive.
 
Hi James... thanks for the reply... my .mdb is in a folder all it's own so I don't think it's quite the same problem but cheers anyway!!
 
Ok for all those of you who might also be having this trouble.... and judging by the threads out there, plenty are.

I think the secret when setting these values:-
Code:
me.form.filter=""   
or 
me.form.orderby=""

Is to switch-off the filter or orderby first... so:-
Code:
me.form.filteron = false
me.form.filter =""
or
me.form.orderbyon = false
me.form.orderby = ""

This seems to bury the filter and orderby values for good.

BTW, if it's a subform then change the form notation to:-
Code:
me.your_subform_name.form.filter.....  etc
Well, at least it seems to have cured the problems I was having anyway....

Also, one other thing to look out for... I had code in the ApplyFilter event which gathered the latest filter settings and stored them in a table (per user)... don't ask! :)

When me.filteron=false is called, Access immediately fires the ApplyFilter event with an ApplyType of 0 (zero)... At this point and until me.filter="" is called, the form.filter still has its string value. The result of that was I re-recorded the soon-to-be redundant filter. I got around this by adding:-

Code:
Me.Form.OnApplyFilter = ""
'.... delete filter code here
Me.Form.OnApplyFilter = "[Event Procedure]"
and then updating my user table to clear it manually..

HTH someone out there... taken me literally months to sort it...
 
Last edited:

Users who are viewing this thread

Back
Top Bottom