Microsoft KB Archive/165359

= ACC97: Dynamic Combo Box to Filter Access Data in IDC Format =

Article ID: 165359

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q165359



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



SUMMARY
You can filter Microsoft Access data in HTX/IDC format by specifying criteria from a Web browser. One way that you can do this is to export a parameter query from Microsoft Access to HTX/IDC format. An HTML file is created, which enables you to type criteria into a text box in order to filter the records returned to the browser. However, you may prefer to select criteria from a combo box based on a table or query in the database. To implement a combo box that you can use from a browser, you must create an additional IDC file and a corresponding HTX file.



MORE INFORMATION
The following example uses the Northwind sample database. It assumes that you have Microsoft Personal Web Server or Microsoft Internet Information Server installed on your Web server computer.

NOTE: This article contains information about writing and editing IDC and HTX files. This information is provided as is. Microsoft Access Technical Support professionals do not support customizing your IDC or HTX files.

 On your Web server, create a System DSN based on the Northwind sample database, Northwind.mdb, and name the data source Nwind97. Start Microsoft Access and open the Northwind sample database. On the File menu, click Save As HTML. When the "Publish to the Web Wizard" appears, click Next on the opening screen. On the "What do you want to publish?" screen, click the Orders table, and then click Next. Click Next on the screen that prompts you to select a default template. On the "What default format type do you want to create?" screen, click Dynamic HTX/IDC, and then click Next.</li> On the "What are, or will be, the settings for the Internet database?" screen, enter Nwind97 in the Data Source Name box, and then click Next.</li> On the "Where do you want to publish to?" screen, select a folder on your Web server where you have Execute permission, for example InetPub\Scripts or Webshare\Scripts, and then click Finish. The Publish to the Web Wizard creates two files, Orders_1.htx and Orders_1.idc.</li>  Start a text editor, such as Notepad, and type the following lines:

 <pre class="fixed_text">       datasource: Nwind97 template: Custlist.htx SQLStatement: +SELECT customers.customerid, customers.companyname +FROM customers

Save this file in the same folder on your Web server where you saved Orders_1.idc, and name this new file Custlist.idc. </li>  Open a new file in your text editor and type the following lines.

NOTE: Substitute the relative path to the location on your Web server where you saved Orders_1.idc in the line <FORM METHOD = "POST" ACTION = "/scripts/Orders_1.idc">

 <pre class="fixed_text">     <HTML> <TITLE>Customers</TITLE> <BODY> <FORM METHOD = "POST" ACTION = "/scripts/Orders_1.idc"> Select the customer whose orders you'd like to see:<BR>

<SELECT NAME = "customerid"> <%BeginDetail%> <OPTION VALUE = <%customerid%>> <%companyname%> <%EndDetail%> </SELECT> <P> <INPUT TYPE = "Submit" VALUE = "Submit"> </BODY> </HTML>

Note that the <%BeginDetail%> and <%EndDetail%> tags determine where the records returned from the database will appear; column names are enclosed in <%%> to indicate where IDC will insert the dynamic data.

Save this file in the same folder on your Web server where you saved Orders_1.htx, and name this new file Custlist.htx. </li>  Open Orders_1.idc in your text editor, and change the following line:

<pre class="fixed_text">       SELECT * FROM [Orders]

to

<pre class="fixed_text">       SELECT * FROM [Orders] WHERE customerid = '%customerid%'

Save the file and close it. </li> Start Microsoft Internet Explorer 3.0 or another Web browser program and type the Universal Resource Locator (URL) for Custlist.idc in the address box. For example:

http://%3Cservername%3E/scripts/custlist.idc</li> Select a customer name in the combo box and click the Submit button. The only orders that display will be those for the customer you selected.</li></ol>

<div class="references_section">