Clearing the filter on a form

G

Guest

I am using code to set filters for my form based upon what the user selects
in a combo box. I would like to clear the filter before the form is closed or
before it is opened each time to speed up our application. Currently, each
time I open the form, the status bars states that a query is running and I'm
guessing that is because there is still a filter applied to the form. Because
of this, the form takes longer to open. Is there a way to avoid this?
 
J

John W. Vinson

I am using code to set filters for my form based upon what the user selects
in a combo box. I would like to clear the filter before the form is closed or
before it is opened each time to speed up our application. Currently, each
time I open the form, the status bars states that a query is running and I'm
guessing that is because there is still a filter applied to the form. Because
of this, the form takes longer to open. Is there a way to avoid this?

I'd suggest putting code in the Form's Close event:

Private Sub Form_Close(Cancel as Integer)
Me.Filter = ""
Me.FilterOn = False
End Sub

It might be useful to do so in the form's Open event (as well or instead).

John W. Vinson [MVP]
 
R

Roel Schreurs

Normally, a filter should not be stored in the form definition when
you apply it during run-time.

Could it be that you are setting a server filter in an Access data
project? There is an issue with Access storing Server filters. As a
test, try to compile your database or project into a .ade or .mde file
and see if the problem still occurs.

As a work-arond, you might be able to set the (Server)Filter property
to an empty string in the Form_Open Event.

I your situation is different, please give some more details.
 

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