Microsoft KB Archive/264791

= ACC2000: Filter by Form with Combo Box Does Not Work in an Access Project =

Article ID: 264791

Article Last Modified on 6/28/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q264791



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

This article applies only to a Microsoft Access project (.adp).



SYMPTOMS
In an Access project, when you run a filter by form that has a combo box, after you select an item from the combo box and apply the filter, you receive the following error messages:

Cannot apply filter on one or more fields specified in the Filter property.

&quot;Microsoft Access didn't apply the filter. Microsoft Access may not be able to apply the filter if you entered an invalid data type in one of the fields. Do you want to close the filter anyway?&quot;



CAUSE
The filter is not applying the bound column of the combo box. Access needs the bound column to look up the matching records.



RESOLUTION
Instead of running a filter by form that has a combo box, create a form that emulates query-by-form by implementing custom Visual Basic for Applications code. For additional information about emulating query-by-form, click the article number below to view the article in the Microsoft Knowledge Base:

235359 ACC2000: Implementing Query-by-Form in an Access Project



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior
 Create a new Access project that is based on the Northwind database from Microsoft SQL Server 2000. Create a new form that is based on the EmployeeTerritories table.  Add a combo box to the form, and then set the following properties:   ControlSource:  EmployeeID RowSource: &quot;SELECT EmployeeID, LastName FROM Employees&quot; Bound Column: 1 Column Count: 2 Column Width: 0&quot;;1&quot;  Add TerritoryID to the form.</li> View the form in Form view.</li> On the Records menu, point to Filter, and then click Filter by Form.</li> Note that the entries in the list for EmployeeID are listed with the last names as expected.</li> Select Dodsworth from the EmployeeID combo box, and then on the Records menu, point to Filter, and click Apply Filter. Note that you receive the following error:

Cannot apply filter on one or more fields specified in the Filter property.

When you click OK, you receive another error:

Microsoft Access didn't apply the filter. Microsoft Access may not be able to apply the filter if you entered an invalid data type in one of the fields. Do you want to close the filter anyway?

Click Yes to build the filter.</li> View the form in Design view.</li> On the View menu, click Properties. In the property sheet for the form, click to the Data tab. Note that the Filter property of the form is set to:

((EmployeeID=&quot;Dodsworth&quot;))

You would expect the filter to be set to:

((EmployeeID=9))

</li></ol>

Additional query words: pra ComboBox didn t

Keywords: kberrmsg kbbug kbpending KB264791

-

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

© Microsoft Corporation. All rights reserved.