How do I store calculations from a form into a table in Access?

G

Guest

I am performing a simple addition calculation in my form, adding up the
quantity that each store wants for each item
eg.)
Store AAA ; Store BBB
Item One = 2 ; Item One = 3 ; ITEM ONE Total = 5
Item Two = 4 ; Item Two = 0 ; ITEM TWO Total = 4

The numbers 2, 3 were entered manually into the form and then the form
totals all the quantities for Item 1 and gets 5. Then it adds the manually
entered 4 and 0 and gets 4 for the total.

The problem is that I need these totals to be stored back into my main table
so I can use them for other forms, query's and reports. The manually entered
numbers are stored properly since in the "Properties-> Data-> Control source"
is the proper location for the entered values to be stored; but when doing
the calculated totals above I could only get the totals to be added by
putting my formula into that same "Control Source" box, thus it has no place
to store the result.

So is there any way to actually store these numbers back to my table with
the rest of my data? I think if I could find somewhere else to put the
formula in, or else some other place to input the location to store the data
it would work.

Another alternative I figure should work, but I could not figure out was, if
I could just put the formula directly in my table and do the calculations
there, instead of the form, everything would also work out.

I really need help ASAP as this is for my work.

Thanks for any help you can provide.
 
G

Guest

As has been said before, it's not very good practice to store a calculated
value in a table. My suggestion would be to create a query from the table
that has the calculated values in it and use that query for forms, reports,
etc.
 
J

John Vinson

On Tue, 21 Dec 2004 14:01:06 -0800, "Zirfas Ali" <Zirfas
So is there any way to actually store these numbers back to my table with
the rest of my data?

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.


John W. Vinson[MVP]
 

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