Orderby and Filter not clearing

lution

Registered User.
Local time
Today, 00:40
Joined
Mar 21, 2007
Messages
114
I have the following lines in my forms OnClose event:

' Make sure to clear any old filters
Me.Filter = ""
Me.FilterOn = False
Me.OrderBy = ""
Me.OrderByOn = False

However, after closing I open the form in design view and whatever the user's last filter and order were are in there. When the user opens the form, the clear all filters isn't enabled indicating there's no filter and if they apply another one, the user is unable to edit any records ( they get a message saying the record is read only if they try to change any fields).

Any thoughts, recommendations? I've tried putting this in the OnLoad event too but it hasn't helped.

Thanks
Lution
 
the first suggestions I have for you is not to put this kind of code on events that change the state of the target object (in this case, your form). Who knows what will happen when you are closing it, or when you are opening it. I'm guessing that's part of the problem.

The other part is the simple fact that filters suck (no offense intended here). Make sure to check your property sheets for any properties that affect filter changes (like FilterOnLoad). This kind of stuff affects your forms too (unfortunately).

There are probably other factors playing into this problem of yours, but noone would know what they are unless you go into more detail, or upload an image of the code block or something.

Regardless though, the point is that filters are almost as difficult to completely figure out as subforms are... :rolleyes:

One good alternative that's always available in Access is to use the Interface Filter icons when you want to apply them. In code, it works completely different, and you get stuck in "static" situations, like this one...
 
The code I showed was the only thing in my forms close event. I don't apply/set any filters in code (there is no filter/onfilter event code for the form or any controls on the form), its all up to the user to use the UI built into Access if they want to use them.

I had several users get into the situation where they'd end up in read-only mode after they did a filter by form so I thought the best thing to do was to add code to make sure that any filters were cleared as the form closed.
 
could the read only mode be related to the sharing of the file? Maybe it's not related to the filtering code at all...???
 
No, each user has their own front and back-end.
 

Users who are viewing this thread

Back
Top Bottom