ACC2000: Error Applying Filter If the Form's Recordset Property Is Set Programmatically

ID: Q225980


The information in this article applies to:
  • Microsoft Access 2000

Advanced: Requires expert coding, interoperability, and multiuser skills.

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


SYMPTOMS

When you try to apply a filter to a form, you may receive the following error message:

Cannot apply Filter on one or more fields specified in the Filter property.
When you click OK, you receive the following error message:
An unknown error has occurred.
When you click OK again, you see that no filter is applied.


CAUSE

You are setting the Recordset property for a form programmatically, and you tried to apply a filter to the form.


RESOLUTION

If you plan to use a filter on a form, do not set the Recordset property of the form programmatically. Instead, base the form on a query or a table.


STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.


MORE INFORMATION

CAUTION: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.

Steps to Reproduce Behavior

  1. Open the sample database Northwind.mdb.


  2. Create a new form with the following properties:


  3. 
       Form: Test1
       -----------------
       Caption: TestForm
    
       Text Box
       -----------------------
       Name: LastName
       ControlSource: LastName
    
       Combo box
       ------------------------
       Name: ReportsTo
       ControlSource: ReportsTo 
  4. Set the OnOpen property of the form to the following event procedure:


  5. 
    Private Sub Form_Open(Cancel As Integer)
    
       Dim rst As ADODB.Recordset
    
       Set rst = New ADODB.Recordset
    
       rst.Open "Employees", CurrentProject.Connection, _
         adOpenKeyset, adLockBatchOptimistic
        
       Set Me.Recordset = rst
    
    End Sub 
  6. View the form in Form view.


  7. Right-click the ReportsTo combo box, and then click Filter By Selection.

    Note that you receive the error messages mentioned in the "Symptoms" section of this article.


Additional query words: pra

Keywords : kberrmsg kbdta
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: September 2, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.