Microsoft Knowledge Base Email Alertz

Setting the Filter property of a form does not apply the filter.

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 208507 - Last Review: March 10, 2003 - Revision: 1.1

ACC2000: Setting the Filter Property of a Form Does Not Apply the Filter

This article was previously published under Q208507
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies only to a Microsoft Access database (.mdb).

On This Page

SYMPTOMS

Setting the Filter property of a form does not apply the filter.

CAUSE

The Filter property holds the filter that is applied when the filtering process is started, but does not start the filtering process.

RESOLUTION

You must set the FilterOn property of the form to True to apply the filter. If you want the filter to be applied when the form opens, you can set the FilterOn property to True on the Open event of the form by using a macro or Visual Basic code, or you can apply the filter manually.

Method 1: Using a Macro

To apply a filter when the form is opened, create the following macro and set the form's OnOpen property to the following macro:
Action: SetValue
Item: FilterOn
Expression: True

Method 2: Using Visual Basic Code

To apply a filter when the form is opened, set the form's OnOpen property to the following event procedure:
Private Sub Form_Open(Cancel As Integer)
   Me.FilterOn = True
End Sub
				

Method 3: Applying a Filter Manually

To apply a filter after the form is opened:
  • Click Apply Filter on the Form View toolbar.

    -or-
  • Click Apply Filter/Sort on the Records menu.

MORE INFORMATION

Steps to Reproduce Behavior

CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

  1. Open the sample database Northwind.mdb.
  2. Open the Orders form.
  3. Press CTRL+G to open the Immediate window. In the Immediate window, type the following line, and then press ENTER:
    Forms!Orders.Filter = "OrderID = 10926"
    Note that nothing is returned.
  4. In the Immediate Window, type the following line, and then press ENTER:
    Forms!Orders.FilterOn = True
    Note that the filter is now applied.

REFERENCES

For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:
212536  (http://kbalertz.com/Feedback.aspx?kbNumber=212536/EN-US/ ) OFF2000: How to Run Sample Code from Knowledge Base Articles
For more information about creating a macro, click Microsoft Access Help on the Help menu, type create a macro in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

APPLIES TO
  • Microsoft Access 2000 Standard Edition
Keywords: 
kbprb KB208507
       

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