G
Guest
I am running a query to balance our credits and invoices for the month.
Although a record could have several lines with different quantities and
amounts, I also have to track the amount of the original invoice. The
TotalOriginal field is entered just once with the main table for the record.
Unfortunately, my query has to look at all line items in the subform to
total those amounts and it is causing redundant data for the TotalOriginal
field. Is there an easy way (either in the query or report) to only sum that
field only one time for each record number (called TransactionID)?
Please see my pasted SQL from the query for more detail. Any advice would
be qreatly appreciated.
SELECT tblTransactionRequest.TransactionID, tblTransactionRequest.Division,
tblTransactionRequest.Product, tblTransactionRequest.Requestor,
tblRequestor.Function, tblTransactionRequest.ReasonCode,
tblTransactionRequest.TotalOriginal, tblInvoiceLines.Quantity,
tblInvoiceLines.[Unit Price], tblTransactionRequest.InvoiceRequest,
tblTransactionRequest.CreditRequest,
tblTransactionRequest.ForcedCreditRequest, tblTransactionRequest.RequestDate
FROM (tblRequestor RIGHT JOIN tblTransactionRequest ON
tblRequestor.RequestorID = tblTransactionRequest.Requestor) RIGHT JOIN
tblInvoiceLines ON tblTransactionRequest.TransactionID =
tblInvoiceLines.TransactionID
GROUP BY tblTransactionRequest.TransactionID,
tblTransactionRequest.Division, tblTransactionRequest.Product,
tblTransactionRequest.Requestor, tblRequestor.Function,
tblTransactionRequest.ReasonCode, tblTransactionRequest.TotalOriginal,
tblInvoiceLines.Quantity, tblInvoiceLines.[Unit Price],
tblTransactionRequest.InvoiceRequest, tblTransactionRequest.CreditRequest,
tblTransactionRequest.ForcedCreditRequest, tblTransactionRequest.RequestDate
HAVING (((tblTransactionRequest.Division)=220 Or
(tblTransactionRequest.Division)=510) AND ((tblRequestor.Function)=[Enter
Function]) AND ((tblTransactionRequest.ReasonCode)<>"Manual Invoice") AND
((tblTransactionRequest.RequestDate) Between [Start date of report] And [End
date of report]))
ORDER BY tblTransactionRequest.Division, tblTransactionRequest.Product;
Thanks,
Jim
Although a record could have several lines with different quantities and
amounts, I also have to track the amount of the original invoice. The
TotalOriginal field is entered just once with the main table for the record.
Unfortunately, my query has to look at all line items in the subform to
total those amounts and it is causing redundant data for the TotalOriginal
field. Is there an easy way (either in the query or report) to only sum that
field only one time for each record number (called TransactionID)?
Please see my pasted SQL from the query for more detail. Any advice would
be qreatly appreciated.
SELECT tblTransactionRequest.TransactionID, tblTransactionRequest.Division,
tblTransactionRequest.Product, tblTransactionRequest.Requestor,
tblRequestor.Function, tblTransactionRequest.ReasonCode,
tblTransactionRequest.TotalOriginal, tblInvoiceLines.Quantity,
tblInvoiceLines.[Unit Price], tblTransactionRequest.InvoiceRequest,
tblTransactionRequest.CreditRequest,
tblTransactionRequest.ForcedCreditRequest, tblTransactionRequest.RequestDate
FROM (tblRequestor RIGHT JOIN tblTransactionRequest ON
tblRequestor.RequestorID = tblTransactionRequest.Requestor) RIGHT JOIN
tblInvoiceLines ON tblTransactionRequest.TransactionID =
tblInvoiceLines.TransactionID
GROUP BY tblTransactionRequest.TransactionID,
tblTransactionRequest.Division, tblTransactionRequest.Product,
tblTransactionRequest.Requestor, tblRequestor.Function,
tblTransactionRequest.ReasonCode, tblTransactionRequest.TotalOriginal,
tblInvoiceLines.Quantity, tblInvoiceLines.[Unit Price],
tblTransactionRequest.InvoiceRequest, tblTransactionRequest.CreditRequest,
tblTransactionRequest.ForcedCreditRequest, tblTransactionRequest.RequestDate
HAVING (((tblTransactionRequest.Division)=220 Or
(tblTransactionRequest.Division)=510) AND ((tblRequestor.Function)=[Enter
Function]) AND ((tblTransactionRequest.ReasonCode)<>"Manual Invoice") AND
((tblTransactionRequest.RequestDate) Between [Start date of report] And [End
date of report]))
ORDER BY tblTransactionRequest.Division, tblTransactionRequest.Product;
Thanks,
Jim