Querying for lasttransaction date and bank balance

vengsiva

Registered User.
Local time
Today, 06:55
Joined
Jan 9, 2004
Messages
31
I am having a table tblBanktransactions in which are recorded deposits and withdrwals from diffrerent accounts.I want them grouped Bankid wise and find the last transaction date for each bank account.I did this with the following two queries
qryrunningsumdeposits
'Grouping Bankidwise

SELECT a.BankId, a.TransId, a.[Transaction date], a.Deposit, a.Withdrawal, (Select Sum(deposit) from [tblbanktransactions] where [Bankid] =a.Bankid and [TransId] <=a.TransId) AS SumDeposits, (Select Sum(Withdrawal) from [tblbanktransactions] where [Bankid] =a.Bankid and [TransId] <=a.TransId) AS Sumwithdrawal, IIf(IsNull([withdrawal]),[Sumdeposits],[sumdeposits]-[sumwithdrawal]) AS Balance
FROM tblBankTransactions AS a;
Query 2

'Getting the last date of transacion in each bank
SELECT tblBankTransactions.BankId, Max(Format([Transaction date],"dd/mmm/yy")) AS LastDateTransaction
FROM tblBankTransactions
GROUP BY tblBankTransactions.BankId;

So far so good.But I want also the balance on the LastDateTransaction, and I had a module with the following function

GetBalance = DLookup("Balance", "qryrunningsumdeposits", "[Transaction date]= #" & givendate & "#")

But inserting this function in query2 as a field does not work(I am asked to input LastdateTransaction).I got stuck Advance thanks for any help
vengsiva
 

Users who are viewing this thread

Back
Top Bottom