Hi, I am just noticing that the ending balance is correct but there is
an
error on the first line of the query.
dateTime debit credit running
01-Jan-08 $0.00 $40,000.00 $79,800.00
03-Jan-08 $200.00 0.00 $39,700.00
04-Jan-08 $100.00 $0.00 $39,600.00
05-Jan-08 $100.00 $0.00 $39,500.00
17-Jan-08 $60.00 $0.00 $39,440.00
29-Jan-08 $500.00 $0.00 $38,940.00
02-Feb-08 $30.00 $0.00 $38,910.00
This is my code:
SELECT a.[date of transaction],
LAST(a.[Check Amount]) AS debit,
LAST(a.[Deposit Amount]) AS credit,
SUM(b.[Deposit Amount] - b.[Check Amount]) As running
FROM tableNameHere AS a , tableNameHere AS b
WHERE a.[date of transaction] >= b.[date of transaction]
GROUP BY a.[date of transaction]
Thanks
:
Sure:
SELECT a.[date of transaction],
LAST(a.[Check Amount]) AS debit,
LAST(a.[Deposit Amount]) AS credit,
LAST(a.[Check Number]) AS checkNumber,
LAST(a.[Check Name]) AS purpose,
SUM(b.[Deposit Amount] - b.[Check Amount]) As running
FROM
...
Vanderghast, Access MVP
Thanks so much , I got it to work. Is there anyway, I can include
the
Check
number and name in the query.
:
You don't have to have only one column, no (although since we now
use
handheld computer, or computer, there is no real need to have two
columns,
since hand held computer can as easily add than subtract ).
SELECT a.[date of transaction],
LAST(a.[Check Amount]) AS debit,
LAST(a.[Deposit Amount]) AS credit,
SUM(b.[Deposit Amount] - b.[Check Amount]) As running
FROM tableNameHere AS a INNER JOIN tableNameHere AS b
ON a.[date of transaction] >= b.[date of transaction]
GROUP BY a.[date of transaction]
in a new query, in SQL view (still have to change the table name at
two
places, use [ ] around the name if the name has spaces in it.
You can also use a similar version, which will allow you to switch
back
in
design view:
SELECT a.[date of transaction],
LAST(a.[Check Amount]) AS debit,
LAST(a.[Deposit Amount]) AS credit,
SUM(b.[Deposit Amount] - b.[Check Amount]) As running
FROM tableNameHere AS a , tableNameHere AS b
WHERE a.[date of transaction] >= b.[date of transaction]
GROUP BY a.[date of transaction]
and indeed, switching back in design view, you could see what you
could
have
done, graphically, to produce that query (rather than doing it in
SQL
view).
Vanderghast, Access MVP
Do I need to have both deposits and checks in the same column,
and
show
as
negative and positive? I'd rather not if If I don't have to.
:
This is a very simple account. For date it is set to edium
date,
It
is
only
one account so I don't have that as a field. I have fields
named
check
number, check amount, deposit amount, date of transaction, Name,
Status
(for
cashed or uncashed).
When I create the new query in design view and bring the check
book
table,
please tell me exactly what I need to do after I bring down the
fields.
Thanks.
:
You should edit a new query, in SQL view, and type the code.
Missing
the
tableName you have to supply (two places). Also assuming that
[Check
Amount]
is a debit and [Deposit Amount] a credit (still not sure of
your
field
accountNumber and dateTime)
SELECT a.accountNumber,
a.dateTime,
LAST(a.[Check Amount]) AS debit,
LAST(a.[Deposit Amount]) AS credit,
SUM(b.[Deposit Amount] - b.[Check Amount]) As running
FROM tableNameHere AS a INNER JOIN tableNameHere AS b
ON a.accountNumber= b.accountNumber
AND a.dateTime >= b.dateTime
GROUP BY a.accountNumber, a.dateTime
Vanderghast, Access MVP
message
My field names are Check Amount and Deposit Amount. Where
would I
put the
info you gave me. I dont know SQL etc, hust how to work in
the
basic
design
view,
Would you walk me through. Thanks
:
Assuming there is a single transaction, per second, per
account.
Assuming there is a single field, amount, with + and -
for
credit
and
debit: +2000 and -342.44 as example.
SELECT a.account,
a.dateTime,
LAST(a.amount) AS transactionAmount,
SUM(b.amount) As running
FROM tableNameHere AS a INNER JOIN tableNameHere AS b
ON a.account = b.account
AND a.dateTime >= b.dateTime
GROUP BY a.account, a.dateTime
should do the job. I assumed the fields name were account,
dateTime
(for
the
date and time of the transaction) and amount.
Vanderghast, Access MVP
message
I have a check book with deposits and checks written on
the
account. I
would
like to run a query and show a running balance next to
each
entry.
Please
help.