Solved

Applying grouping filter to sql query from dropdown

Posted on 2009-07-07
3
194 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Exception in Log4Net 1 18
Expando 4 33
Windows Service to Receive TCP Packets 4 33
Convert to Hour/minute textbox and compare 3 35
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now