Microsoft KB Archive/264791

From BetaArchive Wiki

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.

"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?"

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.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a new Access project that is based on the Northwind database from Microsoft SQL Server 2000.
  2. Create a new form that is based on the EmployeeTerritories table.
  3. Add a combo box to the form, and then set the following properties:

       ControlSource:  EmployeeID
       RowSource:  "SELECT EmployeeID, LastName FROM Employees"
       Bound Column:  1
       Column Count:  2
       Column Width:  0";1"
                        
  4. Add TerritoryID to the form.
  5. View the form in Form view.
  6. On the Records menu, point to Filter, and then click Filter by Form.
  7. Note that the entries in the list for EmployeeID are listed with the last names as expected.
  8. 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.
  9. View the form in Design view.
  10. 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="Dodsworth"))

    You would expect the filter to be set to:

    ((EmployeeID=9))



Additional query words: pra ComboBox didn t

Keywords: kberrmsg kbbug kbpending KB264791