Reply
Help with CASE Statement
Old 04-30-2004, 03:22 PM Help with CASE Statement
Junior Talker

Posts: 2
Trades: 0
I am expanding an existing form to include more search options. Instead of using a verbose set of nested If/Then statements I am trying to use a single Case statement.

When I post the code I created I get a Server 500 error. Can someone help me straighten out my code?

The idea is: a user can search for a person by name, location, specialty, or age group. The form posts to a 'results' page, and the 'results' page displays their choices.

Here is my 'results' page code:

Quote:
Response.Write "<p>You searched for: <b>"
Do While Request("Name") <> "" Or Request("Specialty") <> "" Or Request("AgeGroup") <> "" Or Request("Clinic") <> ""
Select Case Request
Case when ("Specialty") <> ""
SpecialtiesRS.Filter = "Id=" & Request("Specialty") & ""
SpecialtySearch = SpecialtiesRS("Specialty")
Case when ("AgeGroup") <> ""
AgeGroupRS.Filter = "Id=" & Request("AgeGroup") & ""
AgegroupSearch = AgeGroupRS("AgeGroup")
Case when ("Clinic") <> ""
ClinicsRS.Filter = "Id=" & Request("Clinic") & ""
ClinicSearch = ClinicsRS("Name")
End Select
Loop
Response.Write "<br>" & Request("Name") & SpecialtySearch & AgegroupSearch & ClinicSearch & "</b>.</p>"
Thanks for any suggestions!
PRMac is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 04-30-2004, 03:39 PM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
A case statement can only be used for testing multiple values on one variable. It cannot be used with multiple variables. Your stuck with the 'if' statements.
Anacrusis is offline
Reply With Quote
View Public Profile Visit Anacrusis's homepage!
 
Old 05-03-2004, 02:49 PM
Junior Talker

Posts: 2
Trades: 0
Bummer!

Thanks for the info, Anacrusis.
PRMac is offline
Reply With Quote
View Public Profile
 
Old 05-31-2004, 06:23 AM
Average Talker

Posts: 16
Trades: 0
First of all, don't use <>"", use Length(variable) => 1.

And don't use Loops when you can use FOR TO statements. Always try to narrow down the the options for the If then else statements.

But looking at your results, why not just carry over the form post results? then create a query from these for use in SQL?
TopGun is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help with CASE Statement
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.11853 seconds with 13 queries