How to display expression resullts in a table?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I get information calculated using expressions in a form field to show
up in the associated table field?
 
As a rule you should never storew calculations in a table.
It is considered poor design and can lead to probles. Do
the calculations when displaying a form or report.

Chris
 
Hi, Rich.

This is a common question from new users. The short answer is you probably
don't need or want to.

There's no need to store a calculation in a field because it can be
calculated on-the-fly in a query faster than you can read it from disk.
Moreover, it can only be done by using VBA code, since a form control can
either have its ControlSource property set to the name of a field OR to a
calculation, but not both.

If any of the data used in the calculation is changed outside the context of
your form where the code is run to update the calculated field, either in the
table directly or through another form, the calculated data will no longer be
correct. So the best way to handle this is to recalculate it in a query
every time you need it.

There are very rare exceptions to this. If yours happens to be one of them,
you would assign the value of the calculated control to the field every time
it changes (i.e., in the AfterUpdate event of each control used in the
calculation):

Me![MyField] = Me![MyCalculatedControl]

Hope that helps.
Sprinks
 
How do I get information calculated using expressions in a form field to show
up in the associated table field?

While it is possible, in most cases it is not desirable to do so.
Let's say you have a table that stores room dimensions, Length and
Width. There would be no reason to store room area, as anytime that
information was needed, all you would need to, in a report, or on a
form, is set the control source of an unbound control to
=[Length]*[Width].
Storing this information would be a waste of resources and subject to
error if [Length] or [Width] were subsequently changed.
 
Back
Top