Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2003
    Posts
    225

    Unanswered: Rolling Total in a QUERY!!

    is it possible to have a query carry out a running total, so that it counts the record above and the current entry.....

    example

    Record 1 Total 10 Running total 10
    Record 2 Total 10 Running total 20
    Record 3 Total 30 Running total 50
    Record 4 Total 5 Running total 55

    as i said i need this done in a query if Possible...

    anyone help?

  2. #2
    Join Date
    Feb 2004
    Posts
    25

    Running Totals

    I write two functions. One to clear a Public Running Total (RT) variable which I call before I run the query to reset RT. Then a second function called in the query to pass the new field value, add it to the RT and return value to query column set up like "qryRT: AccumRT(qryField)", replacing qryField with your field that you want accumulated! See below...

    ' Running Total variable
    Public pub_RT As Double

    Function ResetRT()
    pub_RT = 0
    End Function

    Function AccumRT(parm)
    pub_RT = pub_RT + parm
    AccumRT = pub_RT
    End Function

  3. #3
    Join Date
    Mar 2003
    Posts
    225
    cheers but i have no idea what you just said to be honestly.....

    i have attached my database....anychance you could have a little looksy please.

    i thought i could use the DSUM value as shown below from an example i found....

    RunTot: Format(DSum("Freight","Orders","[EmployeeID]<=" & [EmpAlias] & ""),"$0,000.00")

    how can i convert this to suit my needs please or if you think your way is better......either is fine

    cheers

    Andy

    cheers

    Andy
    Attached Files Attached Files

  4. #4
    Join Date
    Feb 2004
    Posts
    25

    Running Totals example

    I created a macro that clears totals and runs qryRunningTotals for you. Enjoy!!
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •