Solved

Applying grouping filter to sql query from dropdown

Posted on 2009-07-07
3
196 Views
Last Modified: 2013-11-08
Below is some ASP code that lets me search through patient data.  I also can apply filters (date of service, department, etc.).  The one that's giving me trouble is the one for "location".

There's 3 different sites, but within each site there's sub locations.  Example, BIHP-IO and BMHP-IO would belong to BH (among others).  You can see the details in the case statement.

SELECT CASE Location WHEN 'BIHP-OT' THEN 'BH' WHEN 'BIHP-H' THEN 'BH'  WHEN 'EMHP-OF' THEN 'EC'...and so on.

How can I search by location and make (for example) BIHP-OT and BIHP-H come up when I select BH from the drop down?  Right now it's sending the "BH" as the filter, and that's not a real location.

My complete code is attached.
<tr>
		<td>Location</td>
		<td>
			<select id="location" name='location'>
				<%
				If varSearchLoc <> "" then
					Response.Write("<option value='" & varSearchLoc & "'>" & varSearchLoc & "</option>")
					Response.Write("<option value=''>--Choose--</option>")
				Else
					Response.Write("<option value=''>--Choose--</option>")
				End If
				%>
				<option value='BH'>BH</option>
				<option value='EC'>EC</option>
				<option value='HD'>HD</option>
			</select>
		</td>
	</tr>

Open in new window

code.txt
0
Comment
Question by:IntercareSupport
3 Comments
 
LVL 9

Accepted Solution

by:
rg20 earned 500 total points
ID: 24798411
I would try a nested query

strlocationsearch = "select * from table where location_table in (select sublocation from location_table where location = " & varSearchLoc  &" )"

Query may need work
0
 
LVL 1

Expert Comment

by:dannocracker
ID: 24798412
If I understand your question, you might want to have two DDLs, one dependent on the other. The 2nd one is populated during run time when a selection is made in the 1st one. If this is correct, let me know and I'll provide more specifics with a code example.
0
 

Author Closing Comment

by:IntercareSupport
ID: 31600795
Thanks!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question