Results 1 to 3 of 3
  1. #1
    SHIVA2016 is offline Novice
    Windows 10 Access 2013
    Join Date
    Jan 2016
    Posts
    6

    Opening Balance and Closing Balance

    Hii


    Having problem with opening & Closing balance query the closing balance are not getting reflected as opening balance month wise. please help me

    screen shot of Table and query are as below

    Click image for larger version. 

Name:	Table-Query.PNG 
Views:	19 
Size:	28.6 KB 
ID:	50138

    Sql:

    SELECT DISTINCT t1.mth, (SELECT (sum(credit - debit)) FROM test AS t2
    WHERE t2.mth <= t1.mth) AS op_bal,
    Sum(t1.credit) AS Cr, Sum(t1.debit) AS Dr,
    Sum((Nz([op_bal])+Nz([credit]))-Nz([debit])) AS cl_bal
    FROM test AS t1
    GROUP BY t1.mth
    ORDER BY t1.mth;

    Thank you

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    your opening balance should not include the current months values

    WHERE t2.mth <= t1.mth) AS op_bal

    should be

    WHERE t2.mth < t1.mth) AS op_bal

    and your closing balance does not look right either -looks like dec-2004 should be -892, not -4000. Not tested but suspect should be

    (SELECT (sum(credit - debit)) FROM test AS t2) WHERE t2.mth <= t1.mth) + sum(nz(credit)-nz(debit)) AS Cl_Bal

    not sure why you are using distinct, your group by is already doing that.

    also think you need to use the nz function in your subquery



  3. #3
    SHIVA2016 is offline Novice
    Windows 10 Access 2013
    Join Date
    Jan 2016
    Posts
    6
    Thank you, My problem has been solved after dropping the Keyword DISTINCT and modifying the WHERE clause
    Its been a great help

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

Similar Threads

  1. Opening balance worked into running balance.
    By Perfac in forum Programming
    Replies: 11
    Last Post: 01-09-2018, 01:20 PM
  2. Replies: 2
    Last Post: 11-22-2015, 11:16 AM
  3. General Ledger Query With Opening Balance and Running Balance
    By muhammadirfanghori in forum Queries
    Replies: 3
    Last Post: 03-12-2015, 07:17 AM
  4. Replies: 3
    Last Post: 04-19-2014, 02:35 AM
  5. Replies: 1
    Last Post: 03-29-2014, 10:19 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