Form to Table update

  • Thread starter Thread starter Kane
  • Start date Start date
K

Kane

I just created my first Access table and associated
form. On the form, I have created one calculated field.
The desired result is displayed in the calcualted field
on the form but this value is not written into this field
in the table. All the other fields entered via the form
are written into the table. What is required to have the
value of the calculated field written out to the table?
 
You generally do not want to store calculated values back to the database.
This is a fundamental principle of database design. That's why they don't
make it easy. Since you have the base values stored, you should just
recalculate them anytime you need them, either in a query, a form, or a
report.
 
Welcome to Access.

This issue comes up frequently. It is normally not
desirable to store a calculated value in your table for
three reasons:

1. You risk changing the data in Table view, where your
form calculation does not apply. This results in a result
that does not match its underlying data.
2. It wastes disk space.
3. It is much quicker to calculate the value on the fly
than read it from the disk.

So for *most* applications, when you need this value, say
for a report, place a calculated field in the underlying
query, such as:

ExtendedPrice: =[Qty]*[UnitPrice]

If yours is the rare case where you want the data stored,
the following code will save it to a field:

Me!<yourfieldname> = Me!<yourformcontrolname>, i.e.,

Me!ExtendedPrice = Me!txtExtd

Place this code in the AfterUpdate event of each control
used in the calculation.

HTH
Kevin Sprinkel
 
Back
Top