Solved I need running balance including add and less in the report field (1 Viewer)

Local time
Tomorrow, 00:36
Joined
Aug 19, 2021
Messages
212
Hi,
I need help calculating a running balance in a report field. Where the debit will accumulate in the balance and the credit will be subtracted from it.
In the image below my report is getting the "CASH IN HAND" transactions from General Journal and showing the balance from there.
1670486224555.png

I also want to show you these transactions in General Journal Query to more clearify my question, please see the query below which is the source of my report:
1670486750452.png

The output of the balance field in my report that I need is:
1670486962921.png

Kindly guide me on how can I calculate my desired values in my report's balance field.

Thank you.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:36
Joined
May 7, 2009
Messages
19,245
something like:

SELECT VoucherDate, VoucherNo, Account, IIF(Debit<>0, "Cash Received", "Paid") As Narration,
Debit, Credit, (SELECT SUM([Debit]-[Credit]) From yourTable AS T Where T.Account = yourTable.Account And T.ID <= yourTable.ID) As Balance
From yourTable Where Account="Cash In Hand" Order By VoucherDate, ID;

the Total you can calculate on your report.
 
Last edited:
Local time
Tomorrow, 00:36
Joined
Aug 19, 2021
Messages
212
something like:

SELECT VoucherDate, VoucherNo, Account, IIF(Debit<>0, "Cash Received", "Paid") As Narration,
Debit, Credit, (SELECT SUM([Debit]-[Credit]) From yourTable AS T Where T.Account = yourTable.Account And T.ID <= yourTable.ID) As Balance
From yourTable Where Account="Cash In Hand" Order By VoucherDate, ID;

the Total you can calculate on your report.
Dear Arnel thank you for your response.
The error is appearing:
1670491715367.png

Also the Cash Received and Paid etc are just an example of narrations. Narration can be contained in the whole sentence.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:36
Joined
May 7, 2009
Messages
19,245
can you upload a sample data with your journal?
 
Local time
Tomorrow, 00:36
Joined
Aug 19, 2021
Messages
212
Hi Arnel I solved this problem but another problem came up with it. I have calculated the running balance with the help of a subquery, and it also appears in the report.
1670585165632.png
But now when I am trying to get its sum
1670585220175.png

in the report I am getting an error.
1670585277094.png

Please guide me about it.
 
Local time
Tomorrow, 00:36
Joined
Aug 19, 2021
Messages
212
Arnel Please check the Sample DB
 

Attachments

  • BTIAccountsDBBlank_Sample.accdb
    1.2 MB · Views: 88

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:36
Joined
May 7, 2009
Messages
19,245
which Report and which Query?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:36
Joined
May 7, 2009
Messages
19,245
to prevent the error, i made another query (AcctLedgerForReport) from AccountLedger.
this new query is the recordsource of the report.

i also made total query (AccountLedger0Total), on the total textbox i just Dlookup() the value on TotalDb, TotalCr of this query.
the balance, just subtract the two textbox.
 

Attachments

  • BTIAccountsDBBlank_Sample.accdb
    1.3 MB · Views: 132

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:36
Joined
Feb 19, 2002
Messages
43,280
If you add the credits and debits together so you have only one column (you can make it very tiny and hide it on the report. You don't need any code or queries, you can use the RunningSum property of a control to show the RunningSum on the report.
 
Last edited:
Local time
Tomorrow, 00:36
Joined
Aug 19, 2021
Messages
212
to prevent the error, i made another query (AcctLedgerForReport) from AccountLedger.
this new query is the recordsource of the report.

i also made total query (AccountLedger0Total), on the total textbox i just Dlookup() the value on TotalDb, TotalCr of this query.
the balance, just subtract the two textbox.
Thank you so much arnel. Its solved.
 

Users who are viewing this thread

Top Bottom