Storing calculated fields again

R

Robert

There is a thread on this a few threads down and I know it's against the
rules but how would I store a calculated value in a table without having
actually to enter a control and trigger an After Update event? This is for
a billing-type program where you have several records that need to be
updated. A field from another table is needed to make this calculation.
The user pulls up the billing which shows the calculated amount and must
then be able to change it if he wants to. The calculation is therefore a
kind of default and needs to be done before the user sees it. The table can
be updated in code before the screen is displayed if necessary, but the
calculation must be displayed, and a lookup is necessary for this. The
final value whetther it is directly from the calculation or the user's entry
must be stored in the table. How best to go about this?

Robert
 
D

Dirk Goldgar

Robert said:
There is a thread on this a few threads down and I know it's against the
rules but how would I store a calculated value in a table without having
actually to enter a control and trigger an After Update event? This is
for a billing-type program where you have several records that need to be
updated. A field from another table is needed to make this calculation.
The user pulls up the billing which shows the calculated amount and must
then be able to change it if he wants to. The calculation is therefore a
kind of default and needs to be done before the user sees it. The table
can be updated in code before the screen is displayed if necessary, but
the calculation must be displayed, and a lookup is necessary for this.
The final value whetther it is directly from the calculation or the user's
entry must be stored in the table. How best to go about this?


I haven't read the thread you refer to, so I'm only going to address the
questions you raised here.

In this case, since the user may override the originally calculated value,
it is appropriate to store the final value, updated or not. This is not
really the same as storing a calculated value, be cause there's an
incalculable modification that has to be allowed for. Good design prohibits
storing values that can easily be recalculated at any time, but this doesn't
fall into that category.

The exact answer to your question depends on whether all the information
needed to calculate the initial, overridable billing amount is known at the
time a new record is begun. If so, I think you could use the Default Value
property of a bound control for this. If not, you may need to use code in
one or more form events to calculate the value as soon as the necessary
contributing factors become known.
 

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