November 30th, 2012, 11:21 AM
Select Case question
Just a quick question from a relative newbie.
Is there a way to write this Case Select dynamically?
With this in the spot to view the call totals.
Calls1 = 0
Calls2 = 0
Calls3 = 0
While not rs.eof
If Rs("Representative") = "Jo Bonner" Then
Calls1 = (Calls1 + rs("Calls"))
If Rs("Representative") = "Martha Roby" Then
Calls2 = (Calls2 + rs("Calls"))
If Rs("Representative") = "Mike Rogers" Then
Calls3 = (Calls3 + rs("Calls"))
I am writing a page that lists a total for all telephone calls to all 435 US Representatives...by 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.
<% = Calls1 %>
<% = Calls2 %>
<% = Calls3 %>
I thought about:
But, that doesn't work. I think I'm close, but not really sure. Does anyone feel up to teaching a little today?
If Rs(“Representative”) = “ ' " & request("Representative") & " ' ” Then
Calls = (Calls + rs("Calls"))
Thanks in advance
December 1st, 2012, 08:18 AM
Why not do you calculations in your SQL statement?
You can then loop through your SELECT and write out the number of calls for each person.
SELECT COUNT(Calls) As NumCalls FROM MyTable
"You'll never be as perfect as BLaaaaaaaaarche."