473,378 Members | 1,384 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Finances on an Access Database

I have created an Access Database to store information from my various bank
accounts and keep track of my finances.

Everything works great, except that I decided not to keep the balance data
on the sheet, only the transaction amount.

I figured it was easier to just add all the previous transaction amounts to
get the balance on any given date (and a single balance adjustment at the
start of the data).

I am regretting this choice now as the code I have created to do it takes
ages......

Does anybody have any bright ideas on how I could do it? (I have included
my code below for an example)

----------------------------------------------------------------------------
--

SELECT [Q:Data].TransDate, Sum([Q:Data].[TransAmount]*-1)
AS Amount, -1*
(SELECT SUM([TransAmount])
FROM [Q:Data] as [Q:Data_1]
WHERE [Q:Data_1].[TransDate] <= [Q:Data].[TransDate]
and [Q:Data_1].[Account]=[Q:Data].[Account])
AS Balance, [Q:Data].Account
FROM [Q:Data]
GROUP BY [Q:Data].TransDate, [Q:Data].Account;

(I then crosstab the returned data so I can chart it)


Nov 12 '05 #1
6 2134
John,

I see you are using a subquery. Dollars to Donuts, that's what is slowing your
query down to a crawl. See if you can do what you want another way including
redesigning your tables to elimiate the subquery.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"John Ortt" <Jo******@Idontwantspamsonoreturnaddress.com> wrote in message
news:40**********@baen1673807.greenlnk.net...
I have created an Access Database to store information from my various bank
accounts and keep track of my finances.

Everything works great, except that I decided not to keep the balance data
on the sheet, only the transaction amount.

I figured it was easier to just add all the previous transaction amounts to
get the balance on any given date (and a single balance adjustment at the
start of the data).

I am regretting this choice now as the code I have created to do it takes
ages......

Does anybody have any bright ideas on how I could do it? (I have included
my code below for an example)

----------------------------------------------------------------------------
--

SELECT [Q:Data].TransDate, Sum([Q:Data].[TransAmount]*-1)
AS Amount, -1*
(SELECT SUM([TransAmount])
FROM [Q:Data] as [Q:Data_1]
WHERE [Q:Data_1].[TransDate] <= [Q:Data].[TransDate]
and [Q:Data_1].[Account]=[Q:Data].[Account])
AS Balance, [Q:Data].Account
FROM [Q:Data]
GROUP BY [Q:Data].TransDate, [Q:Data].Account;

(I then crosstab the returned data so I can chart it)



Nov 12 '05 #2
On Wed, 28 Apr 2004 12:02:14 +0100, "John Ortt"
<Jo******@Idontwantspamsonoreturnaddress.com> wrote:

Sounds like you have the correct design, which frowns on storing
calculated data. Make sure you have indexes on the fields used in any
group by and where clause.

-Tom.

I have created an Access Database to store information from my various bank
accounts and keep track of my finances.

Everything works great, except that I decided not to keep the balance data
on the sheet, only the transaction amount.

I figured it was easier to just add all the previous transaction amounts to
get the balance on any given date (and a single balance adjustment at the
start of the data).

I am regretting this choice now as the code I have created to do it takes
ages......

Does anybody have any bright ideas on how I could do it? (I have included
my code below for an example)

----------------------------------------------------------------------------


Nov 12 '05 #3
"John Ortt" <Jo******@Idontwantspamsonoreturnaddress.com> wrote in message
news:40**********@baen1673807.greenlnk.net...
I have created an Access Database to store information from my various bank accounts and keep track of my finances.

Everything works great, except that I decided not to keep the balance data
on the sheet, only the transaction amount.

I figured it was easier to just add all the previous transaction amounts to get the balance on any given date (and a single balance adjustment at the
start of the data).

I am regretting this choice now as the code I have created to do it takes
ages......

Does anybody have any bright ideas on how I could do it? (I have included
my code below for an example)

Do you have indexes on the tranDate and account columns?
Nov 12 '05 #4
Others here have indicated their agreement with your approach, but that's
actually not the way accounting database systems usually work. The problem
with adding up all transactions to get a current balance is that you must read
-all- the rows to get a balance, and the number of rows grows linearly with
time. No matter how fast it is at any given point, it will be continually
slower from that point forward.

What most systems do is have a table of current fiscal period data, and
included in that is a single balance-forward record that is the balance at the
end of the last previously closed fiscal period. When calculating a current
balance, you do query all the records from the open period, but not the
archived records from previous periods. Fiscal periods are usually in
quarters.

On Wed, 28 Apr 2004 12:02:14 +0100, "John Ortt"
<Jo******@Idontwantspamsonoreturnaddress.com> wrote:
I have created an Access Database to store information from my various bank
accounts and keep track of my finances.

Everything works great, except that I decided not to keep the balance data
on the sheet, only the transaction amount.

I figured it was easier to just add all the previous transaction amounts to
get the balance on any given date (and a single balance adjustment at the
start of the data).

I am regretting this choice now as the code I have created to do it takes
ages......

Does anybody have any bright ideas on how I could do it? (I have included
my code below for an example)

----------------------------------------------------------------------------


Nov 12 '05 #5
"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:nn********************************@4ax.com...
Others here have indicated their agreement with your approach, but that's
actually not the way accounting database systems usually work. The problem with adding up all transactions to get a current balance is that you must read -all- the rows to get a balance, and the number of rows grows linearly with time. No matter how fast it is at any given point, it will be continually
slower from that point forward.


"Slower" is a relative term. For a personal finance database I doubt we are
talking more than a few tens of thousands of transactions. This is nothing
for Access, even with subqeuries that aggregate many rows. If the present
design works, apart from being slow, then adding checkpointing capability is
probably overkill and not worth the effort. Adding one or two indexes on the
other hand takes about 10 seconds.

Nov 12 '05 #6
On Wed, 28 Apr 2004 16:26:18 GMT, Steve Jorgensen
<no****@nospam.nospam> wrote:

<snip>
What most systems do is have a table of current fiscal period data, and
included in that is a single balance-forward record that is the balance at the
end of the last previously closed fiscal period. When calculating a current
balance, you do query all the records from the open period, but not the
archived records from previous periods. Fiscal periods are usually in
quarters.


Most newer systems do not store totals, and do not force you to close
out periods. QuickBooks is a simple example.

Storing totals makes running non-standard monthly reports, comparative
reports, reports for certain divisions or transaction types, etc ...
more difficult.

The exception is systems that allow you to purge historical
treansacitons will generate records to reflect the total impact of the
transactions.

Most companies use month-ends (can be actually month-end or last
business day, or other variations) as their "periods".

Steven R. Zuch
Cogent Management Inc.
Nov 12 '05 #7

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

Similar topics

6
by: John Ortt | last post by:
I have created an Access Database to store information from my various bank accounts and keep track of my finances. Everything works great, except that I decided not to keep the balance data on...
11
by: Rosco | last post by:
Does anyone have a good URL or info whre Oracle and Access are compared to one another in performance, security, cost etc. Before you jump on me I know Oracle is a Cadillac compared to Access the...
64
by: John | last post by:
Hi What future does access have after the release of vs 2005/sql 2005? MS doesn't seem to have done anything major with access lately and presumably hoping that everyone migrates to vs/sql. ...
52
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
49
by: Mell via AccessMonster.com | last post by:
I created databases on Access 2003 and I want to deploy them to users. My code was also done using 2003. If they have Ms Access 2000 or higher, will they be able to use these dbs with all code,...
17
by: Mell via AccessMonster.com | last post by:
Is there a way to find out where an application was created from? i.e. - work or home i.e. - if application sits on a (work) server/network, the IT people know the application is sitting...
2
by: JayDawg | last post by:
I went to the Microsoft Templates page to see if there is a database template for tracking and reporting on personal finances, but there is nothing good, does anyone have one, or know where I can...
11
by: Harel | last post by:
I have a report SQL which have been working for a few weeks. Its large and the target database is large. It has 59 join, and I dont think there is anything I can do about this, since the DB I use...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.