cost calculations in a table

G

Guest

hi, I have set up a table for parts ordering and I want to do a calculation
in one of the fields. I have a unit cost field and a No of units ordered
field and a total cost field. so I want to times No of units ordered by unit
cost to give a total cost and have the result of the calculation display in
the total cost field. How do I write the formula and where do I write it?
please help
 
T

tina

recommend you don't. rule of thumb is: don't store calculated values in
tables.
you're storing the values you need for the calculation - UnitCost and
NoOfUnits. since tables should not be used for data entry/display, you don't
need to display the total cost in a table. just calculate the total cost "on
the fly" whenever you need it elsewhere in the database

.. in a query, use a calculated column, as
TotalCost: [UnitCost] * [NoOfUnits]

in a form or a report, you can use the calculated field from the query, or
calculate and display the value in an unbound textbox where the
ControlSource property is set to
=[UnitCost] * [NoOfUnits]

hth
 
L

Larry Daugherty

I think/hope you're confusing terms for "fields", which exist in
tables, and "controls", which exist on Forms and Reports.

Do not store calculated results in the database, calculate them each
time they are needed.

the data source for txtTotalCost can be =[Unit Cost] * [Units ordered]

note that in the line above you are referencing fields.

HTH
 

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