-----Original Message-----
First, are you sure that you want to store these calculated values?
In a normalized database you should not store values that can be
derived (calculated) from other values. Instead, you merely
recalculate the values when needed. This is easily done by using
queries with calculated field containing expressions identical to
the ones you've used on your form. The rationale behind not storing
derived values is that you have created one field which is now
dependant on values from two other fields. How do you ensure that
the dependant field is updated when the independant fields are
changed? There are no methods at the database level to do this so
this leaves you with the problem of having to do it from the
application level. Trust me, it is difficult to correctly maintain a
calculated value.
Having said all this I will say that there are times when this rule
should be broken (complex calculations which greatly impact
performance) and there are also many times when the rule doesn't
really apply. You have to decide for your own application whether
you really need to store a derived value.
If you decide that you do, then instead of using an expression in the
ControlSource you should create an AfterUpdate events for PF. In
this event you would have the following:
Me.Stax=me.PF*.08
Me.Total=me.PF+me.ST
I don't know what ST is - you would need to add this code to the
AfterUpdate event for that control also. You also need to be aware
that any form that allows updates to this table will need to include
similar code to keep the values of Stax and Total correct. You also
need to prevent users from updating the table directly (via form or
query views) since there is no way to provide this functionality
from table or form view. Granted, I never let my users into a table
via table view anyway but it's worth noting here as well.
--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
I have three fields (other than others) in a table named
say PF, STAX, TOTAL.
I have made a form where the user will enter the
information. However i only want to enter the PF amount.
STAX will be calculated automatically by the formula
=([PF] * .08)
and similarly TOTAL will be calculated as
=[PF]+[ST]
i have entered these expressions in the related Control
source. and it is working fine in the form where it is
calculated automatically. but the table is not being
updated.
please help.
.