UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Removing A Form Filter Completely, Access 2010    
 
   
bugs007
post Jun 6 2020, 06:15 AM
Post#1



Posts: 33
Joined: 1-October 19



Hi all.

Still having a problem completely removing a filter.

The form is ok it is only when I do a sort and filter together on the form that it somehow gets stuck.

If I apply a filter to the form and launch a report the report is filtered correctly.

I then remove the filter and do a sort on the form and the report is sorted correctly with no filter.

If I then remove the form sort all records display in the report as expected.

Next I apply a both a filter and a sort on the form and the report is filtered and sorted correctly.

I then remove the filter and sort from the form and the report again displays all records.

Next I only do a sort on the form. The report does sort but it also applies the previously applied filter which is undesired. Me.Filter prior to report launch does contain the last filter as I msgbox Me.Filter in the form to check. So it is the form at fault retaining the filter.

The only way to clear the filter is to close and reopen the form.

I use the following code on the remove filter/sort button (does not remove a combined filter and sort)

Me.OrderBy = ""
Me.Filter = ""
Me.FilterOn = False
Me.OrderByOn = False
Docmd.Show all records

Have also tried adding DoCmd.RunCommand acCmdRemoveFilterSort with no difference.

Form properties for filter and orderby both cleared before saving the form.

Would love to find a solution as I have spent hours trying to get to the bottom of this. Seem to think this is a bug in Access itself.

Any solutions welcome.

Thanks in advance.
Go to the top of the page
 
GroverParkGeorge
post Jun 6 2020, 07:22 AM
Post#2


UA Admin
Posts: 37,468
Joined: 20-June 02
From: Newcastle, WA


I think your basic assumption might be wrong.

"Next I only do a sort on the form. The report does sort but it also applies the previously applied filter which is undesired. Me.Filter prior to report launch does contain the last filter as I msgbox Me.Filter in the form to check. So it is the form at fault retaining the filter."

There is no reason for a sort to change an existing filter.

These are separate, albeit somewhat related, functions and changing one doesn't necessarily change the other.

If you want to remove the filter before applying a different sort, then you'll need to remove the filter yourself via VBA.


--------------------
My Real Name Is George. Grover Park Consulting is where I did business for 20 years.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
projecttoday
post Jun 6 2020, 07:30 AM
Post#3


UtterAccess VIP
Posts: 12,380
Joined: 10-February 04
From: South Charleston, WV


To remove a filter use Me.FilterOn = True not Me.FilterOn = False.

--------------------
Robert Crouser
Go to the top of the page
 
bugs007
post Jun 6 2020, 08:32 AM
Post#4



Posts: 33
Joined: 1-October 19



I am trying to remove the filter using VBA but it does not respond. See my remove filter button code above.

To clarify the user can do any combination of sort and filter on the form and that combination is used for the reports. So if the user applies a filter and sort then removes that filter and sort and does just a sort the filter is somehow stuck to the sort when launching the report. I can see the stuck filter in the QBE grid.

Have just tried using

Me.Filter = ""
Me.FilterOn = True

It did not help but made it worse as it retains the filter without doing the sort and retains the filter even after closing and reopenig the form.



Go to the top of the page
 
projecttoday
post Jun 6 2020, 08:49 AM
Post#5


UtterAccess VIP
Posts: 12,380
Joined: 10-February 04
From: South Charleston, WV


Me.Filter = ""
Me.FilterOn = True
will clear the filter. Make sure it executes. If not, the only thing I can suggest is posting it.

--------------------
Robert Crouser
Go to the top of the page
 
bugs007
post Jun 6 2020, 12:13 PM
Post#6



Posts: 33
Joined: 1-October 19



I managed to find a workaround.

On the report button I added the following code prior to report launch

If Me.FilterOn = False Then Me.Filter = ""

Works fine now.

Still unsure why doing virtually the same thing on the remove filter/sort button does not work.

Many thanks for your suggestions sofar.
Go to the top of the page
 
pere_de_chipstic...
post Jun 6 2020, 12:29 PM
Post#7


UtterAccess Editor
Posts: 10,664
Joined: 8-November 07
From: South coast, England


Hi bugs007

PMFJI, but how are you setting the filter for the report, does the syntax for the OpenReport include the form filter ie DoCmd.OpenReport "ReportName", acViewNormal, , Me.Filter

and where is OpenReport command in the context of the command to clear the FORM's filter property?

Your code could do something like:
CODE
Dim strCrit as String
If Me.FilterOn then strCrit = Me.Filter
DoCmd.OpenReport "ReportName", acViewNormal, , strCrit

hth

--------------------
Warm regards
Bernie
Go to the top of the page
 
projecttoday
post Jun 6 2020, 12:31 PM
Post#8


UtterAccess VIP
Posts: 12,380
Joined: 10-February 04
From: South Charleston, WV


I think I gave some misinformation earlier. Me.FilterOn = False does in fact disable the filter. But it doesn't clear the filter's contents. Does this make sense?
So If Me.FilterOn = False Then Me.Filter = "" by itself, at least, doesn't do anything.
If you're still interested.

--------------------
Robert Crouser
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    7th July 2020 - 01:26 AM