Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Apr 2009
    Thanked 1 Time in 1 Post

    Running Total in Access

    Hello All,
    I have a query in access in which I would like to create a field named RunningTotal. RunningTotal would be the running total of TotalPaid field every time there is a change in ProgramNumber. In my query I would like the RunningTotal field to show just the total for each Program Number as displayed below

    Thanks for any assistance/guidance!
    Attached Files Attached Files
    Last edited by MOSTATE; 2016-09-02 at 09:11. Reason: Table did not display

  2. #2
    Star Lounger
    Join Date
    Dec 2009
    Findlay, Ohio
    Thanked 7 Times in 7 Posts
    Maybe not what you want but you can do it in vba, you would need to run it after you have all the data.
    Perhaps add a button to run it.
    I tried it on your example and it worked.
    I hope this helps.

    Sub getrunning()
    curtot = 0
    row1 = Cells(2, 1).Value ' get current Num so eliminate a first pass switch
    For i = 2 To 500 ' let's start the loop for 500
    row1cur = Cells(i, 1).Value ' Num
    col2cur = Cells(i, 2).Value ' Paid
    If row1cur = "" Then ' at end?
    Cells(i - 1, 3).Value = curtot 'set previous total
    Exit For ' Okay, everybody out of the pool
    End If
    If row1 = row1cur Then ' Same Num?
    curtot = curtot + col2cur ' add to total
    Cells(i - 1, 3).Value = curtot ' Set previous Num total
    curtot = col2cur ' Grab current row Paid
    row1 = row1cur ' set new Num
    End If
    Next i ' continue loop
    End Sub ' Okay, everybody out of the pool
    Last edited by orangehat; 2016-09-16 at 20:05.

  3. #3
    Super Moderator
    Join Date
    Aug 2001
    Evergreen, CO, USA
    Thanked 65 Times in 64 Posts
    See the MS support article How to create a running totals query... for two different approaches that do not use VBA.

Posting Permissions

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