Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 197220 - Last Review: July 15, 2004 - Revision: 1.1
ACC2000: Cannot Completely Remove Form Filter
This article was previously published under Q197220
Novice: Requires knowledge of the user interface on single-user computers.
When you apply a filter or a sort to a form and then click
Remove
Filter/Sort on the
Records menu, it appears that the filter or sort has been removed. However, if you check the
Filter property and
OrderBy property in a Visual Basic for Applications procedure or in the form's property sheet, you see that these properties contain the values that were in effect before you removed the filter or sort.
The
Apply Filter/Sort and
Remove Filter/Sort commands on the
Records menu change only the values of the
FilterOn and
OrderByOn properties. These commands do not affect the values of the forms's
Filter or
OrderBy properties. Selecting
Remove Filter/Sort on the
Records menu simply sets
FilterOn and
OrderbyOn to
False. As a result, the form displays all of the records, because, although the filter or sort is still present, it is no longer in effect.
Use either of the following methods to completely remove a filter or sort
from a form.
Method 1
Use the form's property sheet to remove the filter or sort. To do so,
follow these steps:
- Open the form in Design view.
- On the Edit menu, click Select Form.
- If the properties sheet is not displayed, on the View menu, click Properties.
- In the form's property sheet, click the Data tab.
- Delete the contents of the Filter box or the OrderBy box.
Method 2
Use a macro or a Visual Basic for Applications procedure to remove a
filter or sort. In the following example, the filter and sort are removed
during the Current event of the form.
Private Sub Form_Current()
If Me.FilterOn = False Then
Me.Filter = ""
Me.OrderBy = ""
End If
End Sub
Note that if you use this event procedure to remove a filter, the only way
to activate the filter again is to re-create it. To re-create the filter, on the
Records menu, point to
Filter, and then click the appropriate command.
Steps to Reproduce Behavior
- Start Microsoft Access and open the sample database Northwind.mdb.
- Open the Customers form in Design view, and add a command button to
the form. Set its properties as follows:
Name: btnShowFilter
Caption: Show Filter
- Set the OnClick property of the command button to the following event procedure:
Private Sub btnShowFilter_Click()
MsgBox Me.Filter
End Sub
- On the Microsoft Visual Basic File menu, click Close and Return to Microsoft Access.
- On the Microsoft Access View menu, click Form View.
- Select the contents of the Country field, which should be Germany.
- On the Records menu, point to Filter, and click Filter By Selection. Note that only the records of customers located in Germany are displayed. The text to the right of the navigation buttons also indicates that the records have been filtered.
- Click Show Filter and note that the value of the Filter property is
((Customers.Country = "Germany"))
- On the Records menu, click Remove Filter/Sort. Note that the records of all customers are now displayed.
- Click Show Filter and note that the value of the Filter property is still as follows:
((Customers.Country = "Germany"))
For more information, search Microsoft Access Help for "Filter property,"
"FilterOn property," "OrderBy property," and "OrderByOn property."
APPLIES TO
- Microsoft Access 2000 Standard Edition
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate