Full Version: command button to remove filters
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
piggitypow
Hello. I'm wondering if anyone could provide me with the OnClick code for a command button. I want the button to remove all filters on a form (I know the user can just go to the "Records" menu heading in Access 2003, but I want to automate this feature). Hopefully an easy one.
voyager
I think this might work, try

DoCmd.RunCommand acCmdRemoveFilterSort

Hope this works,

If it doesnt you could create a macro, using the run command and selecting remove filter and then link the macro to your buttons on click event.

Voyager
piggitypow
Yeah. That should work, but something werid is going on. I have designed a combo box filter with 8 options (based on records in a table). This feature works mostly.

However, I just realized that even if the "Remove Filter" TOOLBAR button is pressed ,the form doesn't actually show all of the records. It just shows the records for the first option in the combo box. The combo box (no default value set) does not change when filters are removed.

Any idea what is going on?
voyager
Im not very good at this but maybe if you set the default value of the combobox to just this ""

I use this in my search form as it is a null value (i think), not sure if it will work for you though

But if it doesnt check out this site below, I find it very good at teaching some new things and improving on what I already have, it might also have a solution to your problem as well

DataPig Technologies

Voyager
GroverParkGeorge
"Filter" as you are using it here, refers only to a filter on the form's recordsource. It has nothing to do with combo or list boxes on the form, as you've learned.

However, I don't think that is the issue here.

First, we need to know how you apply the filter to the form's recordsource in the first place? The form only shows records for the first option in the combobox? How does that work? Do you have code in the "After_Upate" event of the combo box that applies a filter to the form's recordsource, like this?

Me.Filter = "PrimaryKey = " & Me.CboFilter
Me.FilterOn = True



George
TimK
What about this?

Private Sub Command0_Click()
DoCmd.ShowAllRecords
End Sub

frown.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.