use a form to generate data for a new field in a table

I

inACCESSable

i've inherited a table with tree diameters, among other things. i want to add
a new field to the table that has the area for each tree. i've created a new
query to pull out just the diameter. i tried to make a form that linked the
old field, DBH, and new field, BAI. i tried to make a macro for the equation
((d/2)^2)*3.1415. i don't have any idea how to:

-make the macro do the math. i can't get it to refer to the correct object,
"DBH". i don't even know if i'm supposed to use a macro or a "command" or
something else.

-get the data from the form into the new field in the table. the DBH field
(existing) shows in the form, but when i tab (tried a button with "on click",
but the action or whatever for the click wasn't right) to the BAI field, it's
totally blank. and even if it wasn't i don't know if i could get it fill the
table.

i don't know much at all about db or Access, so if i've overlooked some kind
of concept or used the wrong language, sorry. i looked at a book or two, got
some concepts, but don't have any methods down.
 
S

scubadiver

Now that you have pulled the diameter in the query, calculate the area as
well:

(d/2)^2 is equal to (d^2)/4 so the area is (d^2)*3.1415/4

so...

area: (([diam]*[diam]*0.785)

There is usually no need to store calculated information in tables but in
your case, given that the area will remain the same, this won't be a problem
 
I

inACCESSable

scubadiver said:
Now that you have pulled the diameter in the query, calculate the area as
well:

(d/2)^2 is equal to (d^2)/4 so the area is (d^2)*3.1415/4

so...

area: (([diam]*[diam]*0.785)

There is usually no need to store calculated information in tables but in
your case, given that the area will remain the same, this won't be a problem

thanks for the explanation of the expression. however, i have no idea which
object to add that expression to. in the form? in the query? in the macro?
and, sorry to be annoying, i don't know where in the object to put it.
 
S

scubadiver

Put it in the query as I have written it (but without the extra parenthesis)

inACCESSable said:
scubadiver said:
Now that you have pulled the diameter in the query, calculate the area as
well:

(d/2)^2 is equal to (d^2)/4 so the area is (d^2)*3.1415/4

so...

area: (([diam]*[diam]*0.785)

There is usually no need to store calculated information in tables but in
your case, given that the area will remain the same, this won't be a problem

thanks for the explanation of the expression. however, i have no idea which
object to add that expression to. in the form? in the query? in the macro?
and, sorry to be annoying, i don't know where in the object to put it.
 
J

John W. Vinson

i've inherited a table with tree diameters, among other things. i want to add
a new field to the table that has the area for each tree.

No, you really DON'T want to add this new field.

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 in the control source of a Form or a Report
textbox.
 

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