calculated field from a form to table

L

Larry Daugherty

You can but you should not. Instead, calculate the value each time
you need it. Stored values are almost guaranteed to get out of synch
sooner or later.

HTH
--
-Larry-
--

Darren said:
Can you take a calculated field from a form and pull it in to a
table??
 
G

Guest

Ok, makes sense. If i wanted to do it to get a snapshot and save that in the
table, how do you do this?
 
R

Rick Brandt

Darren said:
Ok, makes sense. If i wanted to do it to get a snapshot and save that
in the table, how do you do this?

In the BeforeUpdate event of the form have code that copies the values from
the expression into a hidden control bound to the field you want to save the
value in. Of course any updates to the operand values NOT done with that
form will then cause the saved calculation result to be incorrect so you
have to be careful of that.
 
L

Larry Daugherty

We're not the Relational Cops. We only suggest and advise. You get
to do whatever you want to do in your own applications.

You've named a special case and it may require special treatment. You
could have a new and separate table named for its purpose that stores
the snapshot value with an associated date in that table. Note that,
in almost all cases, it is possible and preferable to calculate the
value when required.

Probably the best way to deal with situations in which the value of a
thing such as *price* or *cost* changes over time is to track the
dates of the changes and the new value at each change. If you want to
present the result that was true at a given time it is only necessary
to calculate the result based on what the value of the variable that
was true at the target time. That makes it unnecessary to store data
that is sure to become invalid.

Another way to go about the above is store the actual value of a
variable that changes over time rather than a pointer to it. That
breaks a different Relational rule but at least makes the basis for
the calculation visible.

Another situation might be something like a *posting* table; i.e.
Quarterly Balances. As the books are closed for one Quarter the new
balance is written to this account's record in that table for this
quarter. Going forward, the Beginning Balance for the new quarter is
taken from that table and entered in the account. All new
transactions are summed with that number to arrive at the Current
Balance.

HTH
 

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