S
Scheetz LLC
I have a join query I use to pull information for statements. I would like
to include a description from the first occurance only of the invoice
details, but when I run the report, it reflects as many lines as there are
line items and posts (and adds) the invoice total as many times as there are
line items.
Here is my query:
SELECT DISTINCTROW tblInvoices.lngCustomerNumber,
tblInvoices.dtmInvoiceDate, tblInvoices.lngInvoiceID,
tblInvoiceDetails.strInvoiceDescription,
IIf([lngJournalNumber]=116,[curTotalAmount],0) AS Charges,
IIf([lngJournalNumber]=110,[curAmountReceived],0) AS Cash
FROM tblCUSTOMER INNER JOIN (tblInvoices INNER JOIN tblInvoiceDetails ON
tblInvoices.lngInvoiceID = tblInvoiceDetails.lngInvoiceID) ON
tblCUSTOMER.lngCustomerNumber = tblInvoices.lngCustomerNumber
UNION SELECT tblPayments.CustomerID, tblPayments.PaymentDate,
tblPayments.PaymentID, tblPaymentDetails.strDescription,
tblPayments.PaymentAmount, NULL
FROM tblPayments
ORDER BY tblInvoices.dtmInvoiceDate;
and here is the result:
12-21-2004 278 12-21-2004 278
Customer Name
Address
City State Zip
Balance Forward: ($233.03)
12/5/2004 42657 BEARING $86.00 ($147.03)
12/5/2004 42657 Cup $86.00 ($61.03)
12/5/2004 42657 RIM $86.00 $24.97
12/5/2004 42664 BEARING $48.93 $73.90
12/5/2004 42664 Cross Kit $48.93 $122.83
12/5/2004 42664 CUP- BEARING $48.93 $171.76
12/5/2004 42664 FLUID GEAR $48.93 $220.69
12/5/2004 42664 LABOR $48.93 $269.62
Any one have any idea how I can pull this and not have it repeat?
Thank You!
to include a description from the first occurance only of the invoice
details, but when I run the report, it reflects as many lines as there are
line items and posts (and adds) the invoice total as many times as there are
line items.
Here is my query:
SELECT DISTINCTROW tblInvoices.lngCustomerNumber,
tblInvoices.dtmInvoiceDate, tblInvoices.lngInvoiceID,
tblInvoiceDetails.strInvoiceDescription,
IIf([lngJournalNumber]=116,[curTotalAmount],0) AS Charges,
IIf([lngJournalNumber]=110,[curAmountReceived],0) AS Cash
FROM tblCUSTOMER INNER JOIN (tblInvoices INNER JOIN tblInvoiceDetails ON
tblInvoices.lngInvoiceID = tblInvoiceDetails.lngInvoiceID) ON
tblCUSTOMER.lngCustomerNumber = tblInvoices.lngCustomerNumber
UNION SELECT tblPayments.CustomerID, tblPayments.PaymentDate,
tblPayments.PaymentID, tblPaymentDetails.strDescription,
tblPayments.PaymentAmount, NULL
FROM tblPayments
ORDER BY tblInvoices.dtmInvoiceDate;
and here is the result:
12-21-2004 278 12-21-2004 278
Customer Name
Address
City State Zip
Balance Forward: ($233.03)
12/5/2004 42657 BEARING $86.00 ($147.03)
12/5/2004 42657 Cup $86.00 ($61.03)
12/5/2004 42657 RIM $86.00 $24.97
12/5/2004 42664 BEARING $48.93 $73.90
12/5/2004 42664 Cross Kit $48.93 $122.83
12/5/2004 42664 CUP- BEARING $48.93 $171.76
12/5/2004 42664 FLUID GEAR $48.93 $220.69
12/5/2004 42664 LABOR $48.93 $269.62
Any one have any idea how I can pull this and not have it repeat?
Thank You!