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

Multiple seach options 1

Status
Not open for further replies.

donniea21

MIS
Feb 16, 2001
75
US
I have a search page consisting of 5 options (3 dropdowns and 2 text fields)
strState = request.form("searchState")
strLOB = request.form("searchLOB")
strDep = request.form("searchDept")
strAreaofComp = request.form("txtAreaOfCompliance")
strRequirement = request.form("txtRequirement")
i am having trouble setting up the SQL statement so a user can search by one or many of these components. The three drops downs have various values including "ALL" if nothing else is specified. The user must specify at least one parameter

Thanks for any help
 
I would try a dirty way :

Code:
strState = request.form("searchState")
strLOB = request.form("searchLOB")
strDep = request.form("searchDept")
strAreaofComp = request.form("txtAreaOfCompliance")
strRequirement = request.form("txtRequirement")

strSQL = "SELECT * FROM TableName WHERE "	
Number = 0
if strState <> &quot;ALL&quot; then
	strSQL = strSQL & &quot; STATE = '&quot;& strState &&quot;' &quot;
	Number = Number + 1
end if
if strLOB <> &quot;ALL&quot; then
	Number = Number + 1
	if Number > 1 then
		strSQL = &quot; AND &quot; & strSQL
	end if		
	strSQL = strSQL & &quot; LOB = '&quot;& strLOB &&quot;' &quot;
end if

'SAME FOR Dep, AreaofComp, Requirements

Let me know...
 
I think it will work...it seems to be going into the if strLOB <> all code though..So if i pick a state and leave LOB to all i get no results..If i pick a state and a LOB i get a result..Probably just a simple error...thanks for the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top