How to Calculate in Access...

L

L. D. James

I've created a database that has an amount in a field called "Gross
Cost".
I have another field called "Process Amount" that I would like to
automatically have a calculated
value of .18 times the value of the "Gross Cost".

Not sure how to explain this, but if the data in the "Gross Cost" for
the record changes, then the associated field in the record "Process Amount"
would automatically change.

I would like to also have another field call, for instance, "Net Cost",
which would be the difference between the fields "Gross Cost" and "Process
Amount".

Thanks in advance for any suggestions or comments.

-- L. James
 
K

Ken Snell

First, it's very unusual to need to store a calculated value in a field.
Doing so means, as you are stating, that you must update that field every
time you change the value of Gross Cost...and you're just asking for the
time when you or your code forgets to do this.

For your example, you should store just the Gross Cost value. Then, you can
display the Process Amount at any time using a calculated field in a query
or using the control source for a control on a form. You just calculate the
result using a expression:

Query calculated field:
ProcessAmount: [Gross Cost] * 0.18

Control source on a form (assuming that Gross Cost is the name of a field in
the form's recordsource):
=[Gross Cost] * 0.18

Do something similar for Net Cost.
 

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