Turning Off Filters on a Form (1 Viewer)

bmcgree1

Registered User.
Local time
Today, 04:28
Joined
Jun 19, 2009
Messages
43
Hello Everyone,
I've had this problem for a while now and I've gotten around it by having a button that closed and reopened the form but there has to be a better way to do this:

When I filter a form, I can't filter it again with a different value until it is closed and reopened. I have been told before that:
Me.Filter = ""
Me. Filter = False
will solve the problem, but it doesn't. Upon further research I find that in the form 'Filter' property the value I just filtered by is saved and if I remove it out from there it does the same thing as if I closed and reopened the form.

But does anyone know how to do this the right away?? Is there code you can put behind a command button to clear out individual form properties, because that would be one good way! Thank you in advance to anyone willing to help!
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 04:28
Joined
Aug 30, 2003
Messages
36,125
Try

Me.FilterOn = False
 

bmcgree1

Registered User.
Local time
Today, 04:28
Joined
Jun 19, 2009
Messages
43
That doesn't work either, thats what I tried before I just forgot the On part in there.
When I run that button, everything shows (like it should) but when I try to filter based on another value, it shows nothing, as if I filtered on a value that doesn't exist.

I have multiple things a user can filter on such as LoanID, Customer Name and Due Date. All of which work, but only when either the form is restarted or the property value cleared out.
 

bmcgree1

Registered User.
Local time
Today, 04:28
Joined
Jun 19, 2009
Messages
43
Anyone else with this problem, I recieved other help to fix it:

Each time I filtered, I needed to turn the filter off, then tell it to look to my control to filter by (not what was still in the memory) and then turn the filter on. the VBA is below in red. (The FieldName refers to the field in your table/query and ControlName is, well, the name of your control :)

For filtering by numbers (such as Autonumber primary key):
Me.FilterOn = False
Me.Filter = "[FieldName] = " & Me.ControlName & ""
Me.FilterOn = True


For filtering by text:
Me.FilterOn = False
Me.Filter = "[FieldName] = '" & Me.ControlName & "'"
Me.FilterOn = True


For filtering by dates:
Me.FilterOn = False
Me.Filter = "[FieldName] = #" & Me.ControlName & "#"
Me.FilterOn = True

Or filter BETWEEN dates:
Me.FilterOn = False
Me.Filter = "[FieldName] Between #" & Me.ControlName & "# And #" & Me.ControlName2 & "#"
Me.FilterOn = True



hope this helps anyone else!


 

Users who are viewing this thread

Top Bottom