Addition with record results

Posted on 2004-11-08
Last Modified: 2010-04-25
Ok, I have an ASP app I'm building. I have a page that returns results from an Access database based on some variables from a form. One of the fields it returns is "hours worked", and I want to add the hours from all the returned records, but I don't know where to start.

For example: Search for records between a certain date range, completed by a certain staff member. It returns 5 records and the hours worked are: 1.5, 2.5, 8.0, 5.0 and 3.5 for each record returned respectively. I'd like to add all of those up to show total hours worked as 20.5 hrs. Thanks for the help.
Question by:Ellis_Juan
    LVL 23

    Accepted Solution


    in You Asp Loop Through them and Add them to sum up

     While not Rs.eof

      TotalHours = Rs("Hours") + TotalHours


    Response.write TotalHours

    Author Comment

    Thanks, that almost worked perfect. I just needed to change it slightly because it wasn't adding the values, it was just placing them next to each other.

    I did this:

    While not reports.eof

      TotalHours = abs(reports("work")) + abs(TotalHours)


    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
    I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    733 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

    21 Experts available now in Live!

    Get 1:1 Help Now