#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2014
    Posts
    11
    Rep Power
    0

    Sum of Different Fields


    Same application as the earlier questions but having a hard time figuring this one out as well. I want to count the number of courses for which the student has below 60%. Right now I'm just displaying a 1 for each course but would like to add these together in some fashion.

    Code:
    <% IF rs_student_query.Fields.Item("pd_01_gbook_grade") < .60 Then response.write 1 End If%><% If rs_student_query.Fields.Item("pd_02_gbook_grade") < .60 Then response.write 1 End If %><% If rs_student_query.Fields.Item("pd_03_gbook_grade") < .60 Then response.write 1 End If%><% If rs_student_query.Fields.Item("pd_04_gbook_grade") < .60 Then response.write 1 End If %><% If rs_student_query.Fields.Item("pd_05_gbook_grade") < .60 Then response.write 1 End If%><% If rs_student_query.Fields.Item("pd_06_gbook_grade") < .60 Then response.write 1 End If %><% If rs_student_query.Fields.Item("pd_07_gbook_grade") < .60 Then response.write 1 End If%><% If rs_student_query.Fields.Item("pd_08_gbook_grade") < .60 Then response.write 1 End If %>
    Any insight would be greatly appreciated!
  2. #2
  3. Lord of the Dance
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Oct 2003
    Posts
    4,123
    Rep Power
    2010
    Can you repost you code with the proper lines and indention?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2014
    Posts
    11
    Rep Power
    0
    Thank you, it is all on one line and writes the number 1 for each course for which the student is below 60%. The code below, for example, would write 11 for the student failing both courses but I would like it to be 2 (so the numbers are added together.

    Code:
    <% IF rs_student_query.Fields.Item("pd_01_gbook_grade") < .60 Then response.write 1 End If%><% If rs_student_query.Fields.Item("pd_02_gbook_grade") < .60 Then response.write 1 End If %>
    Thanks again for the response and hopefully that makes more sense.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    112
    Rep Power
    15
    Would this not work?
    Code:
    <%
    Dim intCount
    intCount = 0
    
    IF rs_student_query.Fields.Item("pd_01_gbook_grade") < .60 Then intCount = intCount + 1
    If rs_student_query.Fields.Item("pd_02_gbook_grade") < .60 Then intCount = intCount + 1
    
    Response.Write(intCount)
    %>

IMN logo majestic logo threadwatch logo seochat tools logo