Solved

Applying grouping filter to sql query from dropdown

Posted on 2009-07-07
3
198 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

837 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