How do i create a formula in access 2003 tabe - ex. =(price)/(gall

R

ronh

i keep getting error 3344 - i am trying to set this up in table, default
value for this field - $ per Galloon - what am i doing wrong?
 
J

Jeff Boyce

Tables in Access don't have formulas. And if you already have the
underlying fields you'd use to do the calculation, why use a redundant field
to store the results? There are occasional business needs to store a
calculated value, but rarely is it either necessary or worth the extra
effort to keep everything synchronized.
 
R

ronh

Jeff - thanks for the response - I have a table where i have fields.... truck
#, date, amount, gallons, store - I would like to have one field named $ per
gallons and have it calc automatically. That way at a glance i could track
price and tell the drivers which stations to hit.

Any ideas on what is the best way to do this in access. I was just trying
to set a field in the table and have the default value be =[amount]/[gallons].

Thanks in advance for any help.

Ron
 
N

Norman Yuan

Do not confuse a database table with a spread sheet. Database table does not
take formula, if any piece of data can be derived from other data, it should
not be stored in database's table. Also, you, as databse user, should not
directly view/edit data in table(s), unless you are designing/developing it.

User should access data in table through form(s). The calculation you want
should carried out when data is loaded to the form.

ronh said:
Jeff - thanks for the response - I have a table where i have fields.... truck
#, date, amount, gallons, store - I would like to have one field named $ per
gallons and have it calc automatically. That way at a glance i could track
price and tell the drivers which stations to hit.

Any ideas on what is the best way to do this in access. I was just trying
to set a field in the table and have the default value be =[amount]/[gallons].

Thanks in advance for any help.

Ron

Jeff Boyce said:
Tables in Access don't have formulas. And if you already have the
underlying fields you'd use to do the calculation, why use a redundant field
to store the results? There are occasional business needs to store a
calculated value, but rarely is it either necessary or worth the extra
effort to keep everything synchronized.

--
Good luck

Jeff Boyce
<Access MVP>
 
J

John Vinson

Any ideas on what is the best way to do this in access. I was just trying
to set a field in the table and have the default value be =[amount]/[gallons].
Storing derived data such as this in your table accomplishes
three things: it wastes disk space; it wastes time (almost
any calculation will be MUCH faster than a disk fetch); and
most importantly, it risks data corruption. If one of the
underlying fields is subsequently edited, you will have data
in your table WHICH IS WRONG, and no automatic way to detect
that fact.

Just redo the calculation whenever you need it, either as a
calculated field in a Query or just as you're now doing it -
in the control source of a Form or a Report textbox.

If you are using your table datasheet as the interface to view your
data... DON'T. That's not the purpose of tables. Tables are to store
data, and *only* to store data. Use a Form for onscreen viewing, and a
Report for printing - and use table datasheet view only for debugging.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Top