473,503 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Running Balance Help wanted

Hi Guys Can anyone help

I am trying to find a way to implement a running balance that will
re-calculate if the date order is changed, or if an earlier record is
changed like you might want to do during a bank statement reconcile.

I am using the following fields

Date|Payment|Deposit|Running_Balance (tblTransactions)

While the records remain in their original order, the running balance
makes sense, but if I move a record to an earlier date, or alter an
earlier record then the running balance no longer makes sense.

I am only experimenting at the moment for a project that starts in
July, so I would appreciate a prod in the right direction.

Regards Bob Dydd

Nov 13 '05 #1
5 6758
You shouldn't be storing the balance. Instead, you should be calculating it
in your query.

How you do that, though, can be slow.

One way is to use DSum("[Deposit]", "MyTable", "[Date] <=" & Format([Date],
"\#mm\/dd\/yyyy\#")

BTW, you should rename your field from Date: that's a reserved word, and you
can run into lots of problems using reserved words.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"bobdydd" <re**************@yahoo.co.uk> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Hi Guys Can anyone help

I am trying to find a way to implement a running balance that will
re-calculate if the date order is changed, or if an earlier record is
changed like you might want to do during a bank statement reconcile.

I am using the following fields

Date|Payment|Deposit|Running_Balance (tblTransactions)

While the records remain in their original order, the running balance
makes sense, but if I move a record to an earlier date, or alter an
earlier record then the running balance no longer makes sense.

I am only experimenting at the moment for a project that starts in
July, so I would appreciate a prod in the right direction.

Regards Bob Dydd

Nov 13 '05 #2
Thanks for the prompt reply Doug

I took on board what you said about naming fields "Date" and made an
alteration in my experimental mdb so that the fields now are just

TransactionID | TransactionDate | Amount | and they are in
(tblTransaction)

I have made a series of expressions:

1. The Microsoft's Basic DSUM in the help system
DSum(expr, domain[, criteria])help systems basic DSUM

which when I use my fields becomes
Balance: DSum("Amount","tblTransaction","TransactionDate")

This just shows a total balance of ALL numbers

2. An alteration to this using an alias based on the TransactionID as
an extra field in the query:
Balance: (DSum("Amount","tblTransaction","[TransactionID]<=" &
[TransactionAlias] & ""))

This worked quite well and when I altered or added a figure in the
amount field the running balance correctly recalculated (after
refreshing)

However the fly in the ointment is that if you alter the date of the
latest entries as you would if you were reconciling a bank account (eg:
One check cashed earlier than another) the balance that was showing
when the entry was originally made is the one that remains with that
entry in it's NEW position.

This means that the query does not show the current balance at the
LATEST Date.

Regards Bob Dydd

Nov 13 '05 #3
I believe I suggested basing DSum on the date, not the Id.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"bobdydd" <re**************@yahoo.co.uk> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Thanks for the prompt reply Doug

I took on board what you said about naming fields "Date" and made an
alteration in my experimental mdb so that the fields now are just

TransactionID | TransactionDate | Amount | and they are in
(tblTransaction)

I have made a series of expressions:

1. The Microsoft's Basic DSUM in the help system
DSum(expr, domain[, criteria])help systems basic DSUM

which when I use my fields becomes
Balance: DSum("Amount","tblTransaction","TransactionDate")

This just shows a total balance of ALL numbers

2. An alteration to this using an alias based on the TransactionID as
an extra field in the query:
Balance: (DSum("Amount","tblTransaction","[TransactionID]<=" &
[TransactionAlias] & ""))

This worked quite well and when I altered or added a figure in the
amount field the running balance correctly recalculated (after
refreshing)

However the fly in the ointment is that if you alter the date of the
latest entries as you would if you were reconciling a bank account (eg:
One check cashed earlier than another) the balance that was showing
when the entry was originally made is the one that remains with that
entry in it's NEW position.

This means that the query does not show the current balance at the
LATEST Date.

Regards Bob Dydd

Nov 13 '05 #4
I have looked at 2 of the Access based Accounting Systems

1. "Yes I Can" from Database creations
2. "Image Acoounting" from Comtech

Both of these systems are designed by men of huge genius and their
answer to the problem of an updateable running balance is NOT TO HAVE
ONE.

A DSUM calculation appears at the bottom of the form which does the
job, but it looks very unfamiliar to a NON ACCESS person who is used to
seeing his UPDATEABLE running balance by the side of each transaction,
as it Qucken, Microsoft Money, Spreadsheet etc.

Anyway, it has got me stumped, but it was a good mental exercise.

Regards Bob

Nov 13 '05 #5
stevemanser
3 New Member
My solution is to have a "Recalc" button that when pressed goes through each record in the recordset of the form, and adds or subtracts values to the current "running_total" field.

Because your form is going to be different to mine, take this code and customise it to your needs. First, the piece of code below allows you to go through the form and affect each record:

With Me.Recordset
If .RecordCount > 0 Then
strBookMark = .Bookmark
.MoveFirst
Do Until .EOF
.edit 'this line is only needed for DAO, delete it if you're using ADO

[*** YOUR MANIPULATION CODE HERE ***]

.Update
.MoveNext
Loop
.Bookmark = strBookMark
End If
End With



For example, my code actually looks like this:

Private Sub Recalc_Click()
x = DLookup("id", "list_accounts", "account_name='Bank'")
z = DLookup("id", "list_accounts", "account_name='Purchases'")
a = DLookup("id", "list_accounts", "account_name='Expenses'")
With Me.Recordset
If .RecordCount > 0 Then
strBookMark = .Bookmark
.MoveFirst
y = Me.trans_amount
Me.running_total.Value = y
.MoveNext
Do Until .EOF
.edit 'this line is only needed for DAO, delete it if you're using ADO
If Me.debit_account = x Then
' if money going into bank account
Me.running_total.Value = y + Me.trans_amount
ElseIf Me.credit_account = x Then
'if money going out of bank account
Me.running_total.Value = y - Me.trans_amount
ElseIf Me.debit_account = z Then
'if money going out on purchases
Me.running_total.Value = y - Me.trans_amount
ElseIf Me.debit_account = a Then
'if money going out on expenses
Me.running_total.Value = y - Me.trans_amount
Else
Me.running_total.Value = y
End If
y = Me.running_total.Value
.Update
.MoveNext
Loop
.Bookmark = strBookMark
End If
End With
End Sub

Steve
Apr 22 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2673
by: Rose | last post by:
A newbie question: I would like my repeater to look like the following where in the Balance column, I want to keep a running balance, like so Description Amount Balance Item 1 $10 ...
2
2519
by: jaypee1978 | last post by:
Anyone know how can I create a running balance in a datagrid? In MS-Access this could be very simple. This is what my sql in MS-Access query: SELECT AccountDetails.AccountDetailID AS...
1
2103
by: Tom Brown | last post by:
I have a report I created which pulls all data by month by category and gives me running totals month by month. My problem is I need the ending balance running total to move down to the next line...
1
2249
by: Tigerlily | last post by:
// Program to create new accounts, perform deposits, withdrawals, and bank //inquiries #include<iostream> #include<fstream> using namespace std; void menu(); int read_accts(int , double ,...
6
7862
by: balancetotal | last post by:
Creating a running sum in continuous form in Access 2003 -------------------------------------------------------------------------------- Hello: I have three forms on my user-interface. ...
2
2147
by: EManning | last post by:
Using A2K. I've got a report/subreport that looks like the following: <main report> Account AAA Beginning Fund Balance: $10,000 <subreport> "Expense" "Total" ...
1
2717
by: BrianMiller | last post by:
I have searched for an answer but have failed to come up with anything that seems to work. I am trying to set up an Access 2003 database for home accounts. I want to create a running sum (a...
2
4013
by: mauking | last post by:
Hello Everyone, Im a certified public accountant here in the Philippines. Im using microsoft access 2000 and 2003 running in a Windows XP environment. Im having a problem of how to calculate a...
0
1376
by: dustonheaven | last post by:
I need to calculate running balance on data containing Null, which is sorted by few columns. As example below, Clr is sorted by Null Desc, then by date, then just by ID. So far, I just come out...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
382
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.