Re: Can't get query to work...
From: Dale Fye (dale.fye_at_nospam.com)
Date: 12/14/04
- Next message: ExcessAccess: "RE: Criteria- "Not like...""
- Previous message: John Spencer (MVP): "Re: Updatable query - unique values"
- In reply to: crispywafers_at_yahoo.com: "Can't get query to work..."
- Next in thread: crispywafers_at_yahoo.com: "Re: Can't get query to work..."
- Reply: crispywafers_at_yahoo.com: "Re: Can't get query to work..."
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 13 Dec 2004 20:34:23 -0500
Crispy,
I think I would start out with a query to sum payments against a specific
invoiceID:
qry_Payments:
SELECT P.InvoiceID, SUM(P.AmountPaid) as InvoiceAmountPaid
FROM Payments
GroupBY P.InvoiceID
Then replace the payments table in your query and make a few minor
adjustments:
PARAMETERS [Specify School Year In Format 9/1/2004] DateTime,
[Trimester Term By Letter "J, D, or M"] Text (
255 );
SELECT Student_Records.StudentID, Student_Records.SLastName,
Student_Records.SFirstName, Orders.TotalTuition,
Payments.InvoiceAmountPaid, Orders.SchoolYear,
Invoices.InvoiceID, Invoices.TriTerm, Invoices.TriAmountDue
FROM Student_Records
INNER JOIN ((Orders
INNER JOIN Invoices ON Orders.OrderID = Invoices.OrderID)
LEFT JOIN qry_Payments Payments ON Invoices.InvoiceID = Payments.InvoiceID)
ON Student_Records.StudentID = Orders.StudentID
WHERE Payments.InvoiceAmountPaid >= Invoices.[TriAmountDue])
AND Orders.SchoolYear=[Specify School Year In Format 9/1/2004]
AND Invoices.TriTerm = [Trimester Term By Letter "J, D, or M"]
ORDER BY Student_Records.SLastName;
However, this may not work the way you want if, for some reason, the student
has multiple invoices during a single semester. Since you don't give the
relationships between all the tables, I'm not going to try to guess on this
one. However, if a student can have multiple invoices during a given
semester, I would change the first query to include both the invoices and
payments tables, and would sum the invoice amounts, and payment amounts for
each student.
HTH
Dale
<crispywafers@yahoo.com> wrote in message
news:1102959191.242904.185350@z14g2000cwz.googlegroups.com...
> Hi,
>
> I have a query I made to show student's that have "paid in full" on
> their invoice balance. My problem arises if the person/parent insteaad
> of making one full payment to the invoice balance with one check-- ends
> up making two or more payments that add up to a full payment. My
> current query only works if the person makes 1 payment that is for the
> full amount.
>
> I would like the query to also show if, for that invoice, the payments
> associated with it "add" up to the amount due. If they do, list the
> student's name.
>
> Help?
>
> Current Query:
>
> PARAMETERS [Specify School Year In Format 9/1/2004] DateTime,
> [Trimester Term By Letter "J, D, or M"] Text ( 255 );
> SELECT Student_Records.StudentID, Student_Records.SLastName,
> Student_Records.SFirstName, Orders.TotalTuition, Payments.AmountPaid,
> Orders.SchoolYear, Invoices.InvoiceID, Invoices.TriTerm,
> Invoices.TriAmountDue
> FROM Student_Records INNER JOIN ((Orders INNER JOIN Invoices ON
> Orders.OrderID = Invoices.OrderID) LEFT JOIN Payments ON
> Invoices.InvoiceID = Payments.InvoiceID) ON Student_Records.StudentID =
> Orders.StudentID
> WHERE (((Payments.AmountPaid)=[TriAmountDue]) AND
> ((Orders.SchoolYear)=[Specify School Year In Format 9/1/2004]) AND
> ((Invoices.TriTerm)=[Trimester Term By Letter "J, D, or M"]))
> ORDER BY Student_Records.SLastName;
>
- Next message: ExcessAccess: "RE: Criteria- "Not like...""
- Previous message: John Spencer (MVP): "Re: Updatable query - unique values"
- In reply to: crispywafers_at_yahoo.com: "Can't get query to work..."
- Next in thread: crispywafers_at_yahoo.com: "Re: Can't get query to work..."
- Reply: crispywafers_at_yahoo.com: "Re: Can't get query to work..."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|