Microsoft KB Archive/163893

= ACC97: IDC Parameter Queries Cannot Use LIKE and Wildcards =

Article ID: 163893

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q163893



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



SYMPTOMS
When you browse to an IDC file that was exported from Microsoft Access 97, the Web browser returns the following error:

Expression cannot be used with the LIKE predicate in query expression.



CAUSE
Because IDC files communicate with ODBC drivers in order to query the back-end data, the SQL statements they contain have different character requirements than typical Microsoft Access SQL statements. IDC files use the percent sign (%) as a wildcard character whereas Microsoft Access uses the asterisk (*). When Microsoft Access exports a query that contains a parameter concatenated with an asterisk, the SQL statement that is generated contains a parameter concatenated with a percent sign. However, the IDC SQL statement does not need the concatenation operator (&). Instead, it simply needs a series of percent signs (%) to be placed after the parameter.



RESOLUTION
Edit the SQL statement in the IDC file so that it doesn't use a concatenation operator, but instead uses the appropriate sequence of percent signs (%).



MORE INFORMATION
NOTE: This section contains information about editing IDC files, and assumes that you are familiar with editing IDC files. Microsoft Access Product Support professionals do not support customization of any HTML, HTX, IDC, or ASP files.

The following example demonstrates how to change the SQL Statement in an IDC file so that it contains the appropriate sequence of parameter and wildcard characters.

 In Microsoft Access 97, open the sample database Northwind.  Create a new query called FindName based on the Customers table:

       Query: FindName ---       Type: Select Query

Field: CompanyName Table: Customers Criteria: Like [EnterName] & "*"  On the Query menu, click Parameters.  Type the following in the Query Parameters dialog box, and then click OK.

        Parameter          Data Type [EnterName]       Text </li> Save the FindName query and close it.</li> Select the FindName query in the Database window, and then click Save As/Export on the File menu.</li> In the Save As dialog box, click "To an External File or Database," and then click OK.</li> In the "Save Query 'FindName' In" dialog box, select Microsoft IIS 1-2 (*.htx;*.idc) in the Save As Type box, and type FindName.htx in the File Name box. Note the folder where the files will be exported to. Click Export. The HTX/IDC Output Options dialog box appears.</li> In the Data Source Name box, enter the name of a System DSN that points to the Northwind sample database. Click OK.

For more information on how to define a system DSN, search the Help index for "ODBC, setting up data sources," and see the following article in the Microsoft Knowledge Base:

159682 "Data Source Name Not Found" Err Msg Opening Web Page</li> Click OK in the Enter Parameter Value dialog box that appears.</li> The HTX/IDC output creates three files: FindName.HTML, FindName.htx, and FindName.IDC.</li> Copy FindName.HTML, FindName.htx and FindName.IDC to a folder on your Web Server computer where you have both Read and Execute permission. Read permission is necessary to browse the HTML file and Execute permission is necessary to run the IDC file.

For more information about configuring Microsoft Internet Information Server (IIS) permissions, please refer to the IIS Help Index, and see the following article in the Microsoft Knowledge Base:

160754 Error "HTTP/1.0 403 Access Forbidden" Browsing IDC Page</li>  Use Notepad or another text editor to open the FindName.IDC file. You need to change the SQL Statement so that it will use the appropriate sequence of parameter and wildcard characters. Change the SQL Statement so that it looks like this:

<pre class="fixed_text">     SQLStatement:SELECT Customers.CompanyName +FROM Customers +WHERE (((Customers.CompanyName) Like '%[EnterName]%%%')); </li> Save the FindName.IDC file and close it.</li> Start Microsoft Internet Explorer 3.0, or another Web browser program.</li> Type the Uniform Resource Locator (URL) in the address box of your Web browser to view FindName.HTML. For example, if you saved your IDC files in a folder called Test in the wwwroot folder of your Web Server, type:

http://%3Cservername%3E/test/FindName.HTML

Note that the URL depends upon where your files are located on the Web Server.</li> The FindName.HTML form opens in your web browser with an [EnterName] box and a Run Query button. Type the letter M into the box, and then click the Run Query button. All records with names that begin with M are returned.</li></ol>

<div class="references_section">