Need Accurate Amount Due

M

mabyn

I've created a query that does "almost" what I want. The way it is set up is:
Column One
COMPANYNAME
Column Two
REGISTRATIONFEE
Column Three
PAYMENTAMOUNT (what's been paid)
Column Four
AMOUNTDUE (Should be RegistrationFee less PaymentAmount)

It works in every instance where the Company paid something but for the ones
that they have not paid, it puts nothing. I need for Column Four to be what
is really due. If someone can help me, I would appreciate it. Thank you.

SELECT [Attendees].[CompanyName], [Payments].[PaymentAmount],
[Registration].[RegistrationFee], ([RegistrationFee]-[PaymentAmount]) AS
AmountDue
FROM Attendees LEFT JOIN (Registration LEFT JOIN Payments ON
[Registration].[RegistrationID]=[Payments].[RegistrationID]) ON
[Attendees].[AttendeeID]=[Registration].[AttendeeID];
 
A

Allen Browne

Use Nz() to substitute zero if the field is null.

This kind of thing:
SELECT [Attendees].[CompanyName],
[Payments].[PaymentAmount],
[Registration].[RegistrationFee],
Nz([RegistrationFee],0) - Nz([PaymentAmount],0) AS AmountDue
FROM ...
 
J

Jeanette Cunningham

Hi mabyn,
when the payment amount is null, it causes a problem with the calculation.

Use the Nz function to change nulls to 0.
Math can handle zeros, but not null.

(Nz([RegistrationFee],0)-Nz([PaymentAmount],0)) AS
AmountDue

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top