Re: Help with query
- From: "graeme34 via AccessMonster.com" <u18757@uwe>
- Date: Fri, 31 Mar 2006 15:43:02 GMT
hi Vincent
Like I said I think I need two seperate queries, one showing all the total
sum of all invoices for each Customer(Account) and another showing all the
payments made by the customer. Then join them by Account Index and use an
expression in the summary subtracting payments from the invoice total....
Structure of tables as follows:
tblAccount:
AccountIndex (PK), Customer (yes/no) Supplier (yes/no), AccountName, Address
Fields...(1,2,3 etc), Town, TelNum, Faxnum,PostCode, CurrentOwed (If supplier)
, CurrentBalance(if Customer) DateAccountOpened
tblSalesOrderLine
SalesOrderNumber(PK), ProductCode(PK), QuantityOrdered, Price, VATRate (FK)...
..plus a few yes/no flags for coding
tblVAT
VATRate (PK), VATValue
Where VATRate is a code for the amount of Value Added Tax i.e 17.5%
I currently have the query for summing the total amount of Invoices each
month for each Customer(Account).....I now need the query for summing the
total of payments, part of Transaction table i.e the TypeOfPosting field can
either be Customer Payment or Pay Supplier
here is what I have so far...
SELECT SO.AccountIndex, T.TypeOfPosting, Sum(T.TransCredit) AS
SumOfTransCredit, Format([DateOfPosting],"mmmm/yy") AS MonthPaid
FROM tblSalesOrder SO INNER JOIN (tblDespatch D INNER JOIN (tblTransaction T
INNER JOIN tblSalesInvoice SI ON T.TransactionNumber = SI.TransactionNumber)
ON D.DespatchNumber = SI.[Despatch Number]) ON SO.SalesOrderNumber = D.
SalesOrderNumber
GROUP BY SO.AccountIndex, T.TypeOfPosting, Format([DateOfPosting],"mmmm/yy");
The problem here is a Transaction (payment) can be for more than one invoice..
..I.e all Invoices are paid in one Transaction....or a number of transaction
this is causing the query to bring a Transaction for each Invoice...i.e
payment £300.00 for 5 invoices...5 records of £300.00 in the query when
summing getting £1500.00, Ive tried different Join type s but to no avail.....
Hope this is enough information....
Vincent Johns wrote:
OK, I've incorporated your new Queries into my version of your database,
as well as three additional Tables ([tblAccount], [tblSalesOrderLine],
and [tblVAT]) that you hadn't mentioned. But it would also help if you
could post sample records from all of your Tables, maybe a couple of
records from each -- enough to illustrate what is happening in your
Queries. Given enough time, perhaps I could puzzle out all the details,
but my answer will mean more to you if the data look realistic. (A
short field name doesn't always convey an accurate idea of what exactly
is supposed to be inside that field, so example values can help
considerably.)
-- Vincent Johns <vjohns@xxxxxxxxxxxxxxxxxx>
Please feel free to quote anything I say here.
Just a quick update....[quoted text clipped - 90 lines]
Ive managed to write the query to summ the payments (sort of)....
showing them...
just dont know how to rectify it :(
--
Message posted via http://www.accessmonster.com
.
- Follow-Ups:
- Re: Help with query
- From: Vincent Johns
- Re: Help with query
- References:
- Help with query
- From: graeme34 via AccessMonster.com
- Re: Help with query
- From: Vincent Johns
- Re: Help with query
- From: graeme34 via AccessMonster.com
- Re: Help with query
- From: graeme34 via AccessMonster.com
- Re: Help with query
- From: Vincent Johns
- Help with query
- Prev by Date: Re: Query Problem - Two or More Records
- Next by Date: Re: Empty Table?
- Previous by thread: Re: Help with query
- Next by thread: Re: Help with query
- Index(es):
Relevant Pages
|