Results 1 to 11 of 11
  1. #1
    bjornas is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2015
    Posts
    17

    Running sum in form with subform


    I am trying to teach myself Access while keeping the books for a school excursion.

    I have to tables, one "Participants" and one "Payment details". They are related by a "Person IDfk" field to a "IDpk" field in the Participant table. I.e., each participant will make several payments.

    I have also made a participant report, with a "Payment Detail" subform that reflects the above. I have also added a Sum Field for each participants payments in the sub-report.

    Now, I would also like to add a field for summing up payments for each class, as well as a grand total for all participants. I know how to this by using the grouping, sorting and summing function. However, I cant get that function to sum together the sums in the several sub-reports.

    Can anyone point me to a solution to this?


    Rgds., Bjørn Olav, Oslo, Norway

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    reports can do running sum, but not a form.

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Your post title says this is about a form but your post suggests this is about a report?
    I'm not following - you are saying you know how to do this for a report but not when it's a subreport?

    Should be doable in a form, but would require a numeric and unique field sorted ascending (PK autonumber would be good) using Dsum function with a filter that DSum's where the PK_id <= Pk_id. Have not tried that but seems logical to me, but likely would have to be in a continuous form.
    Last edited by Micron; 03-22-2022 at 08:16 AM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Tried it on a form just for the fun of it.

    Click image for larger version. 

Name:	1runningSum.jpg 
Views:	25 
Size:	12.9 KB 
ID:	47506 Click image for larger version. 

Name:	2runningSum.jpg 
Views:	24 
Size:	13.4 KB 
ID:	47507

    =DSum("[Field with value to be summed here]","[table name here]","Pk name here <=" & [Pk name here])

    Notes:
    - Pk name here is Pk field name referred to in prior post.
    - No quotes around field name because it's numeric
    - field name and comparison operators are one string component
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    bjornas is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2015
    Posts
    17
    Sorry, my bad. I am talking about A REPORT...

    I will try the dsum suggestion.

    Rgds., Bjørn Olav

  6. #6
    bjornas is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2015
    Posts
    17
    OK, so the subreport has a field called "beløp" (Norwegian = amount). There is also a =sum([beløp]) at the bottom of the subreport, summing up how much each participant has paid. So far, so good.

    In the footer section for "class", there also is a =sum([beløp]) field. This mysteriously returns a *count* of how many participants there are, rather than a sum of the payments.

    I didnt get the DSum function to work properly. I am quite sure I am missing something very essential here.

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Consider posting a db copy that you have compacted then zipped. You could remove whatever is not required to help with report design - just make sure both reports will open with records and that we know which reports are involved if there are a bunch of them. Also make sure we know what report control should sum what. Not sure if the language will be an issue for all of us or not.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    bjornas is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2015
    Posts
    17
    Pls find attached a zipped version of the database. Although it is in Norwegian language, I belive it is self explanatory.

    Thank you for your help in this matter.
    Attached Files Attached Files

  9. #9
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,563
    Hi
    I tend with this particular table structure to create the Report without a SubReport.

    See the example "rptPameldongsliste" in the attached
    Attached Files Attached Files
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  10. #10
    bjornas is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2015
    Posts
    17
    Mike60smart; Precisely what I needed! Thank you!

    One thing though: I adapted your suggestion somewhat. I added the fields for "date", "amount" and "sender" in the details section for the PersonID_FK as you indicated. However, when putting the form to use, those field names mysteriously changed to "Expr1001", "Expr1002" and "Expr1003". They do reflect the data in the "date", "amount" and "sender" fields, however, so I dont bother with that. It was just strange.

    One other thing: I have made the report "smaller", i.a. by using a column layout. Still, the "report footer" section comes on a separate page. I would have suspected that a <CR> was added before the report footer-section. But the "force page break" property for the fotter cetion is set to "none", so it cant be that.

    Any suggestions?


    Rgds., Bjørn Olav

  11. #11
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,563
    Can you upload your current version?
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 06-12-2015, 12:03 AM
  2. Replies: 2
    Last Post: 03-13-2015, 08:34 AM
  3. Running Total on Form with Subform
    By Njliven in forum Forms
    Replies: 1
    Last Post: 06-18-2013, 11:49 AM
  4. Main form running a search on Subform
    By Briansa in forum Access
    Replies: 1
    Last Post: 09-20-2012, 10:29 AM
  5. Replies: 0
    Last Post: 06-21-2009, 01:29 PM

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