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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am trying to make a dynamic searc

Status
Not open for further replies.

NateUNI

MIS
Joined
Jan 3, 2002
Messages
132
Location
US
I am trying to make a dynamic search page. I am using a access database. The problem is that in order to get records returned, it requires me to enter both a name and a ProblemType. If you just enter in just a name, it does not find any records, however if you just input a ProblemType it works...go figure. Any pointers to where the problem is, Thanks alot

*This is the code for the the submit query*

<CFQUERY
DATASOURCE=&quot;employee_info&quot;
NAME=&quot;Departments&quot;>
SELECT Department_ID
FROM Department
ORDER BY Department_ID
</CFQUERY>
<html>
<head>
<title>Problem Search</title>
</head>

<body>

<h2>Please enter your search text below</h2>

<FORM ACTION=&quot;SearchResults.cfm&quot; METHOD=&quot;POST&quot;>
Name: <INPUT TYPE=&quot;text&quot; NAME=&quot;Name&quot;><BR>

Department:
<SELECT NAME=&quot;Department&quot;>
<OPTION>
<CFOUTPUT QUERY=&quot;Departments&quot;>
<OPTION VALUE=&quot;#Department_ID#&quot;>#Department_ID#
</cfoutput>
</select><BR>

Problem Type:
<SELECT name=&quot;ProblemType&quot;>
<OPTION value=&quot;0&quot;>
<OPTION value=&quot;Applied&quot;>Applied
<OPTION value=&quot;Account Locked-out&quot;>Account Locked-out
</SELECT><BR>

Problem Description: <INPUT TYPE=&quot;text&quot; NAME=&quot;ProblemDescription&quot;><BR>

Resolved By: <INPUT TYPE=&quot;text&quot; NAME=&quot;ResolveBy&quot;><BR>

<P>
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;Search&quot;>
<INPUT TYPE=&quot;reset&quot; VALUE=&quot;Clear&quot;>
</form>
</body>
</html>

*This is the search result*

<CFQUERY
DATASOURCE=&quot;help_desk&quot;
NAME=&quot;HelpSearch&quot;>
SELECT *
FROM Help
WHERE 0 = 0

<CFIF Name IS NOT &quot;&quot;>
AND First_Name LIKE '#Name#%'
</CFIF>

<CFIF ProblemType IS NOT &quot;&quot;>
AND Problem_Type = '#ProblemType#'
</CFIF>
</CFQUERY>

<html>
<head>
<title>Problem List</title>
</head>

<body>
<H3>Found #HelpSearch.RecordCount# Results</h3>

<cfloop query=&quot;HelpSearch&quot;>
<cfoutput>


<table align=&quot;left&quot;>

<tr>
<td align=&quot;left&quot; width=&quot;175&quot;><b>Name:</b></td>
<td align=&quot;left&quot;>#First_Name#</td>
<tr>
<td align=&quot;left&quot; width=&quot;175&quot;><b>Problem Type:</b></td>
<td align=&quot;left&quot;>#ProblemType#</td>
</tr>
</table>
</cfoutput>
</cfloop>
</body>
</html>
 
If you input a name only the query will still search for a problem type, because the first option returns '0', and will never be &quot;&quot; (no entry) change the option to &quot;&quot; or the IS NOT to &quot;0&quot; and it should work. Otherwise try to print the SQL that is created out to determin if there is a mistake. Erwin Oosterhoorn
Analyst Programmer,
Roller hockey'er, biker, ice hockey fan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top