Microsoft KB Archive/225980

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

Article ID: 225980

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q225980



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 that this is a problem in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
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.

Steps to Reproduce Behavior
 Open the sample database Northwind.mdb.  Create a new form with the following properties:   Form: Test1 -  Caption: TestForm

Text Box ---  Name: LastName ControlSource: LastName

Combo box Name: ReportsTo ControlSource: ReportsTo   Set the OnOpen property of the form to the following event procedure: 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  View the form in Form view.</li> 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.</li></ol>

Additional query words: pra

Keywords: kbbug kberrmsg kbpending KB225980

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.