Microsoft KB Archive/278613

= How to use multiple criteria with a drop-down menu to query a database in FrontPage =

Article ID: 278613

Article Last Modified on 1/29/2007

-

APPLIES TO


 * Microsoft FrontPage 2000 Standard Edition
 * Microsoft FrontPage 2002 Standard Edition

-



This article was previously published under Q278613



SUMMARY
This article describes how to create a database results page in Microsoft FrontPage that queries a database by using multiple criteria.



MORE INFORMATION
Before you can use the ASP features in FrontPage, you must install the components listed in the following Microsoft Knowledge Base article:

312638 FP: What You Need to Use Active Server Pages (ASP) in FrontPage 2000

Getting started
Create a new Web using the appropriate steps for your version of FrontPage:
 * In FrontPage 2000:
 * On the File menu, point to New, and then click Web.
 * In the New dialog box, click Empty Web.
 * In the Specify the location of the new Web box, type http://localhost/aspMultiSample . Or, type the address of the server that has the FrontPage Server Extensions installed and supports Active Server Pages (ASP).
 * Click OK.
 * In FrontPage 2002:
 * On the File menu, point to New, and then click Page or Web.
 * In the New Page or Web task pane, click Web Site Templates.
 * In the Web Site Templates dialog box, click Empty Web.
 * In the Specify the location of the new Web box, type http://localhost/aspMultiSample . Or, type the address of the server that has the FrontPage Server Extensions installed and supports ASP.
 * Click OK.

Creating the Database Results Page

 * 1) Insert a new page by clicking the New Page button on the Standard toolbar.
 * 2) On the Insert menu, point to Database, and then click Results.
 * 3) In the first step of the Database Results Wizard, click Use a sample database connection (Northwind) and click Next.
 * 4) In the Record Source list, click Employees. Click Next.
 * 5) Click Edit List.
 * 6) In the Displayed Fields dialog box, remove all fields except City and Country. Click OK.
 * 7) Click More Options.
 * 8) In the More Options dialog box, click Criteria.
 * 9) In the Criteria dialog box, click Add. In the Field Name list, click City. In the Comparison list, click Equals. In the Value box, type City . In the And/Or list, click And. Click OK.
 * 10) Click Add. In the Field Name list, click Country. In the Comparison list, click Equals. In the Value box, type Country . In the And/Or list, click And. Click OK.
 * 11) In the Criteria dialog box, click OK.
 * 12) In the More Options dialog box, click OK.
 * 13) Click Next.
 * 14) In the Choose formatting options for the records returned by the query list, click Table - one record per row. Click to select all of the check boxes and then click Next.
 * 15) In step five of the wizard, click Split records into groups, click to select the Add search form check box, and then click Finish.
 * 16) Save the page by clicking Save on the File menu. Name the file Dataresults.asp.

Adding Drop-Down Menus
 Add a drop-down menu for the City:  In the search form, click the City text box and press DELETE. With your cursor in the table cell next to City, point to Database on the Insert menu and then click Results. In the Use an existing database connection list, click Sample, and then click Next. In the Record Source list, click Employees, and then click Next. Click Edit List. In the list of fields, remove all of the fields except City and click OK.</li> Click Next.</li> In the Choose formatting options for the records return by the query list, click Drop-Down List - one record per item.

City should appear in both the Display values from this field and the Submit values from this field boxes.</li> Click Next.</li> Click Display all records together and click Finish.</li></ol> </li> Add the drop-down menu for the Country: <ol style="list-style-type: lower-alpha;"> In the search form, click the Country text box and press DELETE.</li> With your cursor in the table cell next to Country, point to Database on the Insert menu and then click Results.</li> In the Use an existing database connection list, click Sample, and then click Next.</li> In the Record Source list, click Employees, and then click Next.</li> Click Edit List.</li> In the list of fields, remove all of the fields except Country and click OK.</li> Click Next.</li> In the Choose formatting options for the records returned by the query list, click Drop-Down List - one record per item.

Country should appear in both the Display values from this field and the Submit values from this field boxes.</li> Click Next.</li> Click Display all records together and click Finish.</li></ol> </li> <li>Save your page.</li></ol>

Eliminate Duplicate Entries
<ol> <li>Viewing the duplicates: <ol style="list-style-type: lower-alpha;"> <li>On the File menu, click Preview in Browser.</li> <li>If you are prompted to select a browser, select your browser and then click Preview.</li> <li>When your browser opens, click the City or Country drop-down list.

Notice that duplicate entries appear in the City and Country drop-down lists.</li> <li>Close the browser and switch back to FrontPage.</li></ol> </li> <li>Filter out duplicates for the City: <ol style="list-style-type: lower-alpha;"> <li>Double-click the Database Results region for the City drop-down list.

The Database Results Wizard starts.</li> <li>In the Use existing database connection list, click Sample, and then click Next.</li> <li>Click Next.</li> <li>In the Record Source list, click Employees.</li> <li>Select the Custom Query option.</li> <li>Click Edit.</li> <li>In the SQL statement, delete the asterisk (*) and then type DISTINCT CITY. Click OK.</li> <li>Click Next until you reach the end of the wizard and then click Finish.</li></ol> </li> <li>Filter out duplicates for the Country: <ol style="list-style-type: lower-alpha;"> <li>Double-click the Database Results region for the Country drop-down list to start the Database Results Wizard.</li> <li>In the Use existing database connection list, click Sample, and click Next.</li> <li>Click Next.</li> <li>In the Record Source list, click Employees.</li> <li>Select the Custom Query option.</li> <li>Click Edit.</li> <li>In the SQL statement, delete the asterisk (*) and then type DISTINCT COUNTRY. Click OK.</li> <li>Click Next until you reach the end of the wizard and then click Finish.</li></ol> </li> <li>Save your page and preview it in your browser.

Notice that the duplicate entries no longer appear in the City and Country drop down lists.</li></ol>

<div class="references_section">