ACC: Setting Filter Property of Form Does Not Apply Filter

Last reviewed: May 30, 1997
Article ID: Q148299
The information in this article applies to:
  • Microsoft Access versions 7.0, 97

SYMPTOMS

Moderate: Requires basic macro, coding, and interoperability skills.

Setting the Filter property of a form doesn't apply a filter.

CAUSE

The Filter property holds the filter that will be applied when a filter is activated, but does not activate filtering.

RESOLUTION

You need to set the FilterOn property of the form to True to activate 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. You can do this using either a SetValue action in a macro or through Visual Basic code, as demonstrated below.

Using a Macro in the Open Event Procedure of the Form

To apply a filter when the form is opened, create the following macro and set the form's OnOpen property event procedure to this macro:

   Action
   --------
   SetValue

   SetValue Action
   ----------------
   Item: FilterOn
   Expression: True

Using Visual Basic Code in the Open Event Procedure of the Form

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

The filter may also be applied, while the form is open, by simply clicking the Apply Filter button on the built-in toolbar or by clicking the Apply Filter/Sort option on the Records menu.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Open the sample database Northwind.mdb.

  2. Open the Orders form.

  3. Press CTRL+G to open the Debug window. In the Debug window, type the following line, and then press ENTER:

          Forms!Orders.Filter = "OrderID = 10002"
    

    Note that nothing is returned.

  4. In the Debug Window, type the following line, and then press ENTER:

          Forms!Orders.FilterOn = True
    

    Note that the filter is applied.


Keywords : FmsProp kbusage
Version : 7.0 97
Platform : WINDOWS
Hardware : X86
Issue type : kbprb
Resolution Type : Info_Provided


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.