Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Field Query returns all records

Status
Not open for further replies.

boomer963

Technical User
Jul 5, 2000
7
0
0
US
The following statement comes straight from my .IDC file:<br><br>+WHERE ((tblCodes.CompanyCode) = '%CompanyCode%') or <br>((tblCodes.CompanyName) like '%CompanyName%%%')<br><br>What I'd like it to do is enable the user to query for either Company Code or Company Name (two form fields on an HTML page). As written, it currently works fine when searching by Company Name, but returns all records in the database (Access 97) when searching by Company Code.<br><br>How can I get the database to give me only the Company Code I'm looking for?
 
I'm sorry but I don't know what an .IDC file is?&nbsp;&nbsp;Is it something from SQL??<br><br>Where are you getting the parameters from?&nbsp;&nbsp;Do you mean that when you supply only the Company Name and not the Company Code that the query works fine, but not when you only supply the Company Code and not the Company Name?<br><br>Kathryn
 
When exporting a database to the web, Microsoft Access' Web Publishing Wizard creates an HTML extension file (.htx).and an Internet Database Connector file (.idc).<br><br>The .idc file contains a query in the form of an SQL statement and information that Microsoft IIS uses to connect to the database.<br><br>The .htx file is an HTML file that contains formatting tags and instructions, and instead of data, placeholders indicating where to insert the values returned from the query in the .idc file.<br><br>After you publish your database and install your Web application, Microsoft IIS, upon request from a Web browser, opens the database (using the Microsoft Access Desktop Driver and the .idc file connection information), runs the query in the .idc file to access the data, merges the results and .htx file into one .html file, and then sends the .html file back to the Web browser for display as a Web page. Sorry for the long explanation.<br><br>But back to the parameters. Your assessment of the situation was right on: When I supply the company name (or part of the name), the query works fine (regardless of what is in the company code field). When I supply the company code (regardless of what's in the company name field), I get back every record in the database.
 
I think I figured out a solution- it may be a workaround, but it works! Since the two fields are independent searches, I created a second IDC file. The first IDC file (which is pointed at when the user clicks the &quot;submit&quot; button for the Company Code search) has the condition<br><br>WHERE ((tblCodes.CompanyCode) like '%CompanyCode%%%')<br><br>and the second IDC file (which is pointed at when the user clicks the &quot;submit&quot; button for the Company Name search) has the condition<br><br>WHERE ((tblCodes.CompanyName) like '%CompanyName%%%').<br><br>I figured that since the field searches are independent events, the condition need not be related to one another.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top