Great community. Great ideas.

Welcome to ASP/Free, a community dedicated to helping beginners and professionals alike in improving their knowledge of Microsoft's development and administration technologies. Sign up today to gain access to the combined insight of tens of thousands of members.

Thread: Select Case question

Results 1 to 2 of 2
Share This Thread →
  1. #1
    Jackie W is offline Contributing User
    Join Date
    Jul 2004
    Rep Power

    Select Case question

    Just a quick question from a relative newbie.

    Is there a way to write this Case Select dynamically?

    Calls1 = 0
    Calls2 = 0
    Calls3 = 0
    While not rs.eof
    		If Rs("Representative") = "Jo Bonner" Then   
    		Calls1 = (Calls1 + rs("Calls"))
    End if
    		If Rs("Representative") = "Martha Roby" Then   
    		Calls2 = (Calls2 + rs("Calls"))
    End if
    		If Rs("Representative") = "Mike Rogers" Then   
    		Calls3 = (Calls3 + rs("Calls"))
    End if
    With this in the spot to view the call totals.
    <% = Calls1 %>
    <% = Calls2 %>
    <% = Calls3 %>
    I am writing a page that lists a total for all telephone calls to all 435 US state. I don't want to have to write this case select 435 times...but I'm just new enough at this that I'm not sure how to do it dynamically.

    I thought about:

    If Rs(“Representative”) = “ ' " & request("Representative") & " ' ” Then   
    		Calls = (Calls + rs("Calls"))
    End if
    But, that doesn't work. I think I'm close, but not really sure. Does anyone feel up to teaching a little today?

    Thanks in advance

  2. #2
    BLarche is offline Contributing User
    Join Date
    Jan 2007
    Indianapolis, USA
    Rep Power
    Why not do you calculations in your SQL statement?

    SELECT COUNT(Calls) As NumCalls FROM MyTable
    You can then loop through your SELECT and write out the number of calls for each person.
    "You'll never be as perfect as BLaaaaaaaaarche."

Share This Thread →

Become Part of This Conversation

Join NowFor Free!

Similar Threads

  1. Select and sum question
    By Jens Simonsen in forum ASP Development
    Replies: 2
    Last Post: December 28th, 2006, 07:17 AM
  2. Select top 1 question
    By miniskirt in forum ASP Development
    Replies: 9
    Last Post: June 6th, 2006, 12:21 AM
  3. Select * From question
    By Levurax in forum Microsoft SQL Server
    Replies: 4
    Last Post: April 25th, 2006, 11:52 AM
  4. question regarding select statement
    By lee82 in forum ASP Development
    Replies: 1
    Last Post: November 5th, 2004, 06:23 AM
  5. select question
    By webb in forum ASP Development
    Replies: 2
    Last Post: October 11th, 2004, 02:53 PM

ASP Free Advertisers and Affiliates