Math question in a query

R

reno.04

Hi

I have a table (tbl_payment) and a client and make payments eg 1 full
payment or many smaller payments.

How can i get all the client's payments add the together and subtract them
from the total fee?

the fields are client ID, fee, payment amount, Payment_due

cheers
 
R

Reggie

Reno, design a new query using the tbl_payment. Add the fields you listed
below to the query grid. Click view/totals from the main menu. Under client
ID set it to Group By. Under the other fields set it to Sum. Close and
Save the query as qtotPayments. Now design a new query and use the
qtotPayments as the record source for this query. Add the payment_amount,
which will be listed as SumOfpayment_amount if you didn't change it in the
first query and add the SumOffee to the query. Now type the following in
the top row (Field Row) of an empty grid:

=[SumOffee]-[SumOfpayment_amount]

You will want to watch for nulls and use the Nz function where applicable.
 
R

reno.04

Hey thanks Reggie that worked a treat but i see what mean about those who
havent paid could u please explain the nz function's use

cheers
sorry to be a pain
Reggie said:
Reno, design a new query using the tbl_payment. Add the fields you listed
below to the query grid. Click view/totals from the main menu. Under client
ID set it to Group By. Under the other fields set it to Sum. Close and
Save the query as qtotPayments. Now design a new query and use the
qtotPayments as the record source for this query. Add the payment_amount,
which will be listed as SumOfpayment_amount if you didn't change it in the
first query and add the SumOffee to the query. Now type the following in
the top row (Field Row) of an empty grid:

=[SumOffee]-[SumOfpayment_amount]

You will want to watch for nulls and use the Nz function where applicable.
--
Reggie

----------
reno.04 said:
Hi

I have a table (tbl_payment) and a client and make payments eg 1 full
payment or many smaller payments.

How can i get all the client's payments add the together and subtract them
from the total fee?

the fields are client ID, fee, payment amount, Payment_due

cheers
 
R

Reggie

Reno, When adding numbers, a field that is null is telling access that the
value for that field = Unknown. So therefore:
Null is the same as Unknown. When you try to add Unknown to something
access gets confused and will display unpredictable results. What you need
to do is use the Nz function. Nz stands for Null Zero. If used in a query
you must specify the value to use if the control is null"

=(Nz([SumOffee],0))-(Nz([SumOfpayment_amount],0))

Lookup Nz in the help file.

--
Reggie

----------
reno.04 said:
Hey thanks Reggie that worked a treat but i see what mean about those who
havent paid could u please explain the nz function's use

cheers
sorry to be a pain
Reggie said:
Reno, design a new query using the tbl_payment. Add the fields you listed
below to the query grid. Click view/totals from the main menu. Under client
ID set it to Group By. Under the other fields set it to Sum. Close and
Save the query as qtotPayments. Now design a new query and use the
qtotPayments as the record source for this query. Add the payment_amount,
which will be listed as SumOfpayment_amount if you didn't change it in the
first query and add the SumOffee to the query. Now type the following in
the top row (Field Row) of an empty grid:

=[SumOffee]-[SumOfpayment_amount]

You will want to watch for nulls and use the Nz function where applicable.
--
Reggie

----------
reno.04 said:
Hi

I have a table (tbl_payment) and a client and make payments eg 1 full
payment or many smaller payments.

How can i get all the client's payments add the together and subtract them
from the total fee?

the fields are client ID, fee, payment amount, Payment_due

cheers
 

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

Similar Threads

Access Query problem 1
Add new record 1
Connecting Payment Data In Two Forms 2
Calculating a text box 9
Form with subform 4
'Enter parameter value' message 1
Query Help One-to-Many 4
formula in excel 2

Top