Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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).

↑ Back to the top


Symptoms

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

↑ Back to the top


Cause

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

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


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� 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.

↑ Back to the top


Keywords: KB208507, kbprb

↑ Back to the top

Article Info
Article ID : 208507
Revision : 2
Created on : 3/10/2003
Published on : 3/10/2003
Exists online : False
Views : 319