Page 2 of 2 FirstFirst 12
Results 16 to 28 of 28
  1. #16
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    The module name is not really important for code to work but it can be changed in the Access (not VBA) navigation pane.



    Since the expression =RunSum has an = sign, this indicates placement should be in a textbox on form.

    I think [SomeField] is supposed to be the field to sum. Use of Nz() function is to assure a value is passed to the function.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  2. #17
    Njliven is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    86
    I got the accumulated totals to work with the following SQL I adapted. I attached this to a subform and connected the parent/child field (ProjectID), but it still gives an accumulated total for the whole table and not just per ProjectID. Can someone now help me fix this problem. I tried grouping on the ProjectID but I get an error telling me the ProjectID is not part of the aggregate function and will not run.

    Here is the SQL I have.

    SELECT T1.RecordID, T1.Month_Year, T1.Projected_Chrgs, T1.Actual_Chrgs, (SELECT Sum(tbl_Projected_Actual.Projected_Chrgs) AS CumProjected


    FROM tbl_Projected_Actual


    WHERE tbl_Projected_Actual.RecordID <= T1.RecordID) AS CumProjected, (SELECT Sum(tbl_Projected_Actual.Actual_Chrgs) AS CumActual FROM tbl_Projected_Actual WHERE tbl_Projected_Actual.RecordID <= T1.RecordID) AS CumActual, T1.ProjectID
    FROM tbl_Projected_Actual AS T1;

  3. #18
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Running sum by group does complicate. The sum must start over when the ProjectID changes. Easily done in a report.

    Do you need to see all groups in one output?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #19
    Njliven is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    86
    No, I do not need to see all the groups at once. Only per projectID. The main information is in the main form and then all the related data in subform(s).
    I got it to work great in the report, but not on the subform or in the graphs.

  5. #20
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I have never needed a running sum and trying to do in query without considering grouping is tough enough. I attempted option 2 in http://support.microsoft.com/kb/290136 but that is not working for me.

    I am afraid this is over my head. Review another recent thread trying running sum https://www.accessforums.net/queries...tml#post239940
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #21
    Njliven is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    86
    Been playing with everything I can find on the Web on running totals in a group. Nothing seems to work for my situation. Any suggestions that might work would be greatly appreciated.

  7. #22
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I know it can be done on report. Accomplishing in query or on form is way too much for me.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #23
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    Let me ask the question again.

    Did you try the SQL in Post #13? That should work.

  9. #24
    Njliven is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    86
    Yes, the query in post #13 works but brings back the wrong amounts, my end total on the first project, which should be correct give me a total of 6,776,500, when it should be only 300,000. It also does the running sum on the whole table. I have several projects in one table and need a running sum for each project. Which is not happening. I thought when the query was attached to a subform and the subform parent/child relationships were established it would do a running total by project, but it does not work that way. So I have been trying to figure out how to run it so it would do a running total on a group. I am also going to need a graph of these accumulated totals and this also needs to be per project. So I believe I need have the query group by the projectID.

  10. #25
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    The DSum would need additional criteria for the projectID. This is what I attempted as explained by the MS article referenced in post 20.

    CDbl(DSum("Actual_Chrgs","tbl_Projected_Actual","C Date([Month-Year]) <= #" & CDate([tbl_Projected_Actual].[Month-Year]) & "# AND projectID=" & [projectID]))
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #26
    Njliven is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    86
    The query runs but the calculated fields show #Error. When I clicked on one of the fields with the #Error. This message shows up.
    Data type mismatch in criteria expression. Not sure where the mismatch is as I cannot seem to find one. In the table Month_Year is set as a date, Projected_Chrgs and Actual_Chrgs are set as double currency and the ProjectID field is a text field.

  12. #27
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    The ProjectID is text field so you just need to quote around the ProjectID.

    CDbl(DSum("Actual_Chrgs","tbl_Projected_Actual","C Date([Month-Year]) <= #" & CDate([tbl_Projected_Actual].[Month-Year]) & "# AND projectID='" & [projectID] & "'"))

    Hope this will work for you.

  13. #28
    Njliven is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    86
    The things you miss when looking at something for too long. Thanks for all who helped out. It is finally working working.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Running Total Query??
    By kwooten in forum Queries
    Replies: 8
    Last Post: 06-15-2012, 06:10 AM
  2. running or sub total using sql query in access
    By learning_graccess in forum Access
    Replies: 4
    Last Post: 10-15-2011, 05:40 AM
  3. Using running total in query to create graphs
    By maggioant in forum Queries
    Replies: 4
    Last Post: 10-02-2009, 05:58 AM
  4. Replies: 2
    Last Post: 09-30-2009, 09:40 AM
  5. Creating a Daily Running Total Query
    By seraph in forum Queries
    Replies: 0
    Last Post: 08-15-2009, 12:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums