Microsoft KB Archive/275071

= ACC2002: Data Access Pages Cannot Filter Records When Certain Words Are Used =

Article ID: 275071

Article Last Modified on 9/27/2006

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q275071



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

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SYMPTOMS
When you try to filter a data access page, you notice that sometimes the filter works as expected and sometimes it does not. It appears as though the filter never works when you use certain words to filter the data.



CAUSE
The wildcard character for SQL Server (the percent sign (%)) together with hexadecimal values are used as escape code delimiters by HTML engines when they parse a Universal Resource Locator (URL).



RESOLUTION
Encode the percent sign as a separately encoded value. In other words, change the character % to %25. When the HTML engine sees the encoded value %25, it interprets the value to be the equivalent of %.

For example, change the following URL http:///Customers.htm?ServerFilter=&quot;Notes LIKE '%Alfreds%'&quot; to: http:///Customers.htm?ServerFilter=&quot;Notes LIKE '%25Alfreds%25'&quot; where  is the name of your Web server.



MORE INFORMATION
URLs typically use standard ASCII characters, but they may also contain characters that do not have a corresponding &quot;display-able&quot; character in a character set. These types of characters must be encoded. For example, if you type a URL that contains a space, before the page can be retrieved, the space is encoded to the three characters %20. This is what typically appears in the Address box in Microsoft Internet Explorer instead of the literal space.

To encode certain characters, URLs use the % character, which is the same character as the wildcard character for SQL Server. Any encoded characters in a URL that are represented by the percent sign are also followed by a two-digit hexadecimal value. Hexadecimal values are made up of the numbers 0 through 9 and the letters &quot;a&quot; through &quot;f.&quot;

This means that any server filter that contains the % character as a wildcard character that is followed by a hexadecimal values (0 through 9 and &quot;a&quot; through &quot;f&quot;) will not work. Only alpha characters &quot;g&quot; through &quot;z&quot; that follow the % character will work. For example, %G% will work, but %F% will not.

In the example in the &quot;Steps to Reproduce the Behavior&quot; section, a server filter includes %a as part of its string. The HTML engine interprets this as an escape code instead of as a SQL Server wildcard character followed by the letter &quot;a&quot;. The string %Alfreds% is not completely passed to the server filter property of the Microsoft Office Data Source Control (MSODSC). The resulting filter instead appears as CompanyName LIKE ' lfreds%' (note the space before the letter &quot;l&quot;).

The following example reproduces the problem that is described in this article. The steps assume that your Access 2002 computer also has a Microsoft certified Web server installed on the same computer.

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 the Behavior
 Open the sample database Northwind.mdb. Create a new data access page that is based on the Customers table. Save the page as Customers.htm to your Web server under C:\Inetpub\Wwwroot.  In Microsoft Internet Explorer, browse to this page by using a URL similar to: http:///Customers.htm?ServerFilter=&quot;CompanyName LIKE '%Alfreds%'&quot; where <ServerName> is the name of your Web server. Note that no records are returned, even though the word &quot;Alfreds&quot; is in the Company Name field for Customer ID ALFKI. </li> Remove the letter &quot;a&quot; from the word &quot;Alfreds&quot; in the URL, and then press ENTER. Note that the record for Customer ID ALFKI is returned.</li></ol>

Additional query words: prb problems filtering

Keywords: kbfix kbprb KB275071

-

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

© Microsoft Corporation. All rights reserved.