Results 1 to 5 of 5
  1. #1
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544

    Running sum including Bal Fwd from subreport

    Good morning all from the frozen tundra. I need to create a billing statement that includes a balance forward, if it exists, easy enough, did it with a subreport, but I also need to include that balance forward in the running sum (over all)….is this even possible or am I spinning my wheels? I don't have anything to show because I really don't know what to do! TIA brilliant minds!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Q1 to pull the prev sum,
    Q2 to pull current data,
    Q3 a union query of Q1&2, then report on Q3.

  3. #3
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Thanks RanMan, I'm not getting the results I need. Here are my queries.
    For current accounts
    Code:
    SELECT AsmtsandAccounts.MemberID_FK, AsmtsandAccounts.UseDate,DatePart("m",[useDate]) AS M, DatePart("yyyy",[useDate]) ASY, AsmtsandAccounts.Note, AsmtsandAccounts.AsmtType, AsmtsandAccounts.DBAmount,AsmtsandAccounts.Details, AsmtsandAccounts.DBDate, AsmtsandAccounts.CRAmount,AsmtsandAccounts.CRDATE, AsmtsandAccounts.BAL, AsmtsandAccounts.EnteredBy,AsmtsandAccounts.CheckNumber, AsmtsandAccounts.Comments, AsmtsandAccounts.CText
    FROM AsmtsandAccounts
    WHERE(((DatePart("m",[useDate]))=DatePart("m",[Forms]![runassessments]![daterun]))AND((DatePart("yyyy",[useDate]))=DatePart("yyyy",[Forms]![runassessments]![DateRun])))OR (((DatePart("yyyy",[useDate]))=DatePart("yyyy",[Forms]![runassessments]![DateRun])));
    
    For past due accounts (balance forward)
    Code:
    SELECT AccountsBalFWD2.MemberID_FK, Sum(AccountsBalFWD2.BALFWD) ASSumOfBALFWD
    FROM AccountsBalFWD2
    GROUP BY AccountsBalFWD2.MemberID_FK;
    And the union query
    Code:
    SELECT AccountBalFWD3.MemberID_FK, First(AccountBalFWD3.SumOfBALFWD) ASFirstOfSumOfBALFWD, AsmtsandAccountsCurrentMonth.DBAmount,AsmtsandAccountsCurrentMonth.CRAmount, AsmtsandAccountsCurrentMonth.BAL
    FROM AccountBalFWD3 INNER JOIN AsmtsandAccountsCurrentMonth ONAccountBalFWD3.MemberID_FK = AsmtsandAccountsCurrentMonth.MemberID_FK
    GROUP BY AccountBalFWD3.MemberID_FK, AsmtsandAccountsCurrentMonth.DBAmount,AsmtsandAccountsCurrentMonth.CRAmount, AsmtsandAccountsCurrentMonth.BAL;
    And the results for one member;
    MemberID_FK FirstOfSumOfBALFWD DBAmount CRAmount BAL
    10 $449.43 $0.00 $449.43 ($449.43)
    10 $449.43 $56.18 $0.00 $56.18
    10 $449.43 $168.53 $0.00 $168.53

    What am I missing? I am trying to get the First of the bal fwd with no luck. Thanks again!!

  4. #4
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Ok, I figured out the union query and here it is:
    Code:
    SELECT AccountsBalFWD2.MemberID_FK, Sum(AccountsBalFWD2.BALFWD) AS SumOfBALFWD
    FROM AccountsBalFWD2
    GROUP BY MemberID_FK;
    UNION SELECT AsmtsandAccounts.MemberID_FK, AsmtsandAccounts.BAL
    FROM AsmtsandAccounts
    WHERE (((DatePart("m",[useDate]))=DatePart("m",[Forms]![runassessments]![daterun])) AND ((DatePart("yyyy",[useDate]))=DatePart("yyyy",[Forms]![runassessments]![DateRun]))) OR (((DatePart("yyyy",[useDate]))=DatePart("yyyy",[Forms]![runassessments]![DateRun])));
    That gives me the correct amounts, however, I need additional information in the report and when I link the union query to another query to get that information I get a bunch of duplicates. How do I get rid of them? I need to show all transactions for the current month as line items, the balance forward, and the grand total due (and of course the running sum). Thanks again!
    MemberID_FK Balance Forward UseDate Note DBAmount CRAmount
    10 449.43 1/18/2019 PMT-#5937 $0.00 $449.43
    10 168.53 1/18/2019 PMT-#5937 $0.00 $449.43
    10 -449.43 1/18/2019 PMT-#5937 $0.00 $449.43
    10 56.18 1/18/2019 PMT-#5937 $0.00 $449.43
    10 449.43 1/28/2019 March 2019 Monthly Asmt Lot 1255 $56.18 $0.00
    10 168.53 1/28/2019 March 2019 Monthly Asmt Lot 1255 $56.18 $0.00
    10 -449.43 1/28/2019 March 2019 Monthly Asmt Lot 1255 $56.18 $0.00
    10 56.18 1/28/2019 March 2019 Monthly Asmt Lot 1255 $56.18 $0.00
    10 449.43 1/28/2019 March 2019 Monthly Asmt Lot 1283 $168.53 $0.00
    10 168.53 1/28/2019 March 2019 Monthly Asmt Lot 1283 $168.53 $0.00
    10 -449.43 1/28/2019 March 2019 Monthly Asmt Lot 1283 $168.53 $0.00
    10 56.18 1/28/2019 March 2019 Monthly Asmt Lot 1283 $168.53 $0.00

    The subreport needs to look like this:Click image for larger version. 

Name:	olddbstatement.PNG 
Views:	7 
Size:	26.8 KB 
ID:	37195 I probably should have lead with that.
    Last edited by Gina Maylone; 01-31-2019 at 04:32 AM.

  5. #5
    Gina Maylone is offline Always learning
    Windows 10 Access 2016
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    I took a different route and am using a temp table. Thanks all for the look!

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

Similar Threads

  1. Replies: 2
    Last Post: 03-21-2018, 02:30 PM
  2. Replies: 2
    Last Post: 03-09-2015, 01:06 PM
  3. Replies: 5
    Last Post: 11-30-2014, 08:12 PM
  4. Including SQL statement in VBA
    By mr879 in forum Programming
    Replies: 14
    Last Post: 05-16-2014, 02:38 PM
  5. Replies: 1
    Last Post: 04-15-2013, 10:02 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