Clearing a filter from a form property sheet


F

fredg

Hi;
When i define a filter for a form thru code and apply it to that form,it
will be saved in the form's property sheet in background.This causes some
troubels when i want to mix condidtions and make another filter based on
user's request.So i need to erease the filter property from the property
sheet first,before making a new filter and apply it,through code.To do this,
i use the expression: frm.filter = "" ,where frm is the target form.but
unfortunately this cant clear filter from the form's property sheet.What
expression can do this for me?(clearing filter property from the property
sheet)
Any help wd be appreciated and thank you in advance.

Leave the filter property alone, it's not hurting anybody.

When you are through with the filter, you can use code to set the
FilterOn property to False:

Me.FilterOn = False

Then, whenever you want another filter, create a new Filter, either by
code and set FilterOn = True, or using Access Filter by Form (or
Selection) and hitting the Filter button. The new filter will replace
the old.
 
Ad

Advertisements

A

Allen Browne

In the Open event of the form, you can set the form's filter to a
zero-length string, unless it really was opened with a filter:

Private Sub Form_Open(Cancel As Integer)
If Not Me.FilterOn Then
Me.Filter = ""
End If
End Sub
 
M

Mota

Hi;
When i define a filter for a form thru code and apply it to that form,it
will be saved in the form's property sheet in background.This causes some
troubels when i want to mix condidtions and make another filter based on
user's request.So i need to erease the filter property from the property
sheet first,before making a new filter and apply it,through code.To do this,
i use the expression: frm.filter = "" ,where frm is the target form.but
unfortunately this cant clear filter from the form's property sheet.What
expression can do this for me?(clearing filter property from the property
sheet)
Any help wd be appreciated and thank you in advance.
 
M

Mota

Dear fred;
I know this.But when a user want to add a condition to the form filter,(a
custom function wd do this in my program,i.e. new conditions will be added
to the old ones),i have to read the form's filter property to make a new
filter expression.Till now,i have now problem.My problem raises when next
time user opens this form.I expect there is no filter for it in opening and
selected condition be the first one.In fact what i want is to remove any
filter expression in the form's property sheet,when it closes,to be ready
for the next opening.Im wondering why setting filter property to "" in form
close or Unload event (Frm.Filter ="") wont do this.Can you please help me
to do this?
Thank you for your attention.
 
Ad

Advertisements

M

Mota

Its going to be a wondering problem for me.
I tried that code,but still when my "MakeFilterExpr" function (a public
function attached to a CmdFilter command button on each bound form) want to
see if a filter present,it finds the previous one,although i set it to a
zero length string in open event of the form ! It seems there is no way to
delete a filter from a form's property sheet.
Instead,how can we retreive "FilterByForm" thru VBA code?It may be more
useful than my custom function to make complex filter expressions.
Thank you for your help.
 

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