Get rid of filter string

  • Thread starter Pedro Bezunartea via AccessMonster.com
  • Start date
P

Pedro Bezunartea via AccessMonster.com

How can I get rid of any filters that have been applied to a form _before_ it is closed and the filter string is saved for the next time you open it?

The following won't work:

Private Sub Form_Open(Cancel As Integer)
Me.Filter = ""
Me.FilterOn = False
End Sub

This doesn't work because the old filter string magically stays there... why? If you try to apply _another_ filter, they get mixed up.

I have reviewed all the posts I've been able to find on the subject unluckily.

I just want to make sure the form is closed without any filters... is this possible?

Thaks,

Pedro Bezunartea.
 
V

Van T. Dinh

Use the Form_Unload Event instead.

--
HTH
Van T. Dinh
MVP (Access)




Pedro Bezunartea via AccessMonster.com said:
How can I get rid of any filters that have been applied to a form _before_
it is closed and the filter string is saved for the next time you open it?
The following won't work:

Private Sub Form_Open(Cancel As Integer)
Me.Filter = ""
Me.FilterOn = False
End Sub

This doesn't work because the old filter string magically stays there...
why? If you try to apply _another_ filter, they get mixed up.
 
P

Pedro Bezunartea via AccessMonster.com

It doesn't work. When I open the form again, the filter string is still there. Filter is not active though.

Can anybody give me a reasonable explanation why is this happening?

TIA

Pedro.
 
K

Ken Snell [MVP]

When you close the form, do you use

DoCmd.Close acForm, Me.Name, acSaveYes


As for why it does this, it's the way MS designed forms.... it's been the
source of complaints, but...until and unless MS changes it in future
versions, that is what ACCESS does.
 
P

Pedro Bezunartea via AccessMonster.com

I guess that's the only solution:
1. Disable the close button in the form.
2. Add a button to close the form with the code:
DoCmd.Close acForm, Me.Name, acSaveNo

I still don't understand why the code (Me.Filter = "") doen't work in the
open, close, or unload events... anyone? is there any reasonable
explanation why this works this way?

Thanks a lot,

Pedro Bezunartea.
 
K

Ken Snell [MVP]

Explanation? Just that that is the way the software developers in MS
programmed ACCESS.
 
P

Pedro Bezunartea via AccessMonster.com

Explanation? Just that that is the way the software developers in MS
programmed ACCESS.

That's why I asked for a "reasonable explanation"... ;) I don't know
something tike... The form filter property get's overwritten by the session
filter property which can be set ...

just keep trying an easier way to do things. And, BTW! Althogh I disabled
the close button it still appears with access 2003, which actually makes
the solution useless. :(

Any other ideas?

Pedro.
 
K

Ken Snell [MVP]

No, I'm afraid not. Is there a problem with that filter string remaining
there? So long as the Filter is not turned on, the string is ignored. And if
you set a different filter, or open the report with a filtering string in
the DoCmd.OpenReport action, it'll overwrite the one that is there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top