From: Graeme on
Hello
I palnning on implementing calculation between two fields, and the result within another field. Suppose I have three fields called A B and C respectively. In the form I plan on Inputing a value for[A] and Inputing a value for [B]. Now, Field [C] will calculate [A]-[B]. When filed [C] is calculated, it is not in the table, like A and B are. I would like to know how to solve this problem.

---
frmsrcurl: http://msgroups.net/microsoft.public.access/
From: Jeff Boyce on
It is rarely necessary to store a calculated value in a table in Access.
Much more commonly, a form (as you are using) or a query is used to do the
calculation "on the fly", as it were.

Since the values in either [A] or [B] could change, what about the idea of
adding code to the AfterUpdate event of BOTH of those controls,
recalculating the displayed (but not stored) value for the control [C]?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"Graeme" <user(a)msgroups.net/> wrote in message
news:%23xbSQ0QzKHA.5936(a)TK2MSFTNGP04.phx.gbl...
> Hello
> I palnning on implementing calculation between two fields, and the result
> within another field. Suppose I have three fields called A B and C
> respectively. In the form I plan on Inputing a value for[A] and Inputing a
> value for [B]. Now, Field [C] will calculate [A]-[B]. When filed [C] is
> calculated, it is not in the table, like A and B are. I would like to know
> how to solve this problem.
>
> ---
> frmsrcurl: http://msgroups.net/microsoft.public.access/


From: KenSheridan via AccessMonster.com on
There is no problem; the value in C is a computed value derived from the
values of A and B, and can be computed whenever required in a computed
column in a query or a computed control in a form or report. To store the
computed value in a column I the table would introduce redundancy and leave
the table at risk of inconsistent data. Delete the C column from the table
and compute the value whenever necessary; that way it is guaranteed that
there will be no inconsistency between the computed value and the values from
which it is derived.

Ken Sheridan
Stafford, England

Graeme wrote:
>Hell
>I palnning on implementing calculation between two fields, and the result within another field. Suppose I have three fields called A B and C respectively. In the form I plan on Inputing a value for[A] and Inputing a value for [B]. Now, Field [C] will calculate [A]-[B]. When filed [C] is calculated, it is not in the table, like A and B are. I would like to know how to solve this problem.
>
>---
>frmsrcurl: http://msgroups.net/microsoft.public.access/

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access/201003/1

From: ghetto_banjo on
You may find it best not to store Field C in the table at all.
Storing fields that are calculated from other fields can be a little
dangerous for data integrity. If someone updates Field A or B, Field
C could then be storing the incorrect value.

Instead, just calculate C whenever you need it via a query/report.
From: Daryl S on
Graeme -

First, is control [C] bound to a field in the table?
Second, when are you calculating [C]? It should be before the record is
saved (e.g. in the BeforeUpdate event on the form (not on the BeforeUpdate of
a field).

--
Daryl S


"Graeme" wrote:

> Hello
> I palnning on implementing calculation between two fields, and the result within another field. Suppose I have three fields called A B and C respectively. In the form I plan on Inputing a value for[A] and Inputing a value for [B]. Now, Field [C] will calculate [A]-[B]. When filed [C] is calculated, it is not in the table, like A and B are. I would like to know how to solve this problem.
>
> ---
> frmsrcurl: http://msgroups.net/microsoft.public.access/
> .
>