Calculated field

  • Thread starter Thread starter cris
  • Start date Start date
C

cris

I have a table that contains the following relevant
fields:

Number of good complete rolls
Number of labels on a roll
number of partial rolls
number of labels on a partial roll
Total labels

Total labels =
(number of good complete rolls * numberof labels on a
roll) + (number of partial rolls * number of labels on a
partial roll)

I put the total labels field on the form and put in the
calculated expression and the field updates on the form
but not in the table. How do I get the calculated data
into the table.

I know this isn't the best design but the user
requirements insist that this h appens.

Thx
 
Thx for the reply. I still need a little more
direction. Please clarify...how do I access the Form
After Update event? Am I being too literal? I tried to
put it in the event property AfterUpdate for the
Calculated field in the following manner:[Record Source
TotGoodLabels]=[GoodLabels]. TotGoodLabels being the
name of the field in the table and GoodLabels the name of
the calculated field. That didn't work. Then I tried
putting it in event for the TotGoodLabels field on the
form. That didn't work either. If you can please
straighten me out. I'm feeling very confused.

Cris
-----Original Message-----
cris,
In the Form AfterUpdate event code:
Me.[RecordSource Total Labels field]=[Calculated form
field]
Ron
-----Original Message-----
I have a table that contains the following relevant
fields:

Number of good complete rolls
Number of labels on a roll
number of partial rolls
number of labels on a partial roll
Total labels

Total labels =
(number of good complete rolls * numberof labels on a
roll) + (number of partial rolls * number of labels on a
partial roll)

I put the total labels field on the form and put in the
calculated expression and the field updates on the form
but not in the table. How do I get the calculated data
into the table.

I know this isn't the best design but the user
requirements insist that this h appens.

Thx
.
.
 
I have a table that contains the following relevant
fields:

Number of good complete rolls
Number of labels on a roll
number of partial rolls
number of labels on a partial roll
Total labels

Total labels =
(number of good complete rolls * numberof labels on a
roll) + (number of partial rolls * number of labels on a
partial roll)

I put the total labels field on the form and put in the
calculated expression and the field updates on the form
but not in the table. How do I get the calculated data
into the table.

I know this isn't the best design but the user
requirements insist that this h appens.

I hate it when users insist that you use Bad Design. I'd suggest that
you share my boilerplate rant with the user, just for their
information:

Storing derived data such as this in your table accomplishes
three things: it wastes disk space; it wastes time (almost
any calculation will be MUCH faster than a disk fetch); and
most importantly, it risks data corruption. If one of the
underlying fields is subsequently edited, you will have data
in your table WHICH IS WRONG, and no automatic way to detect
that fact.

Just redo the calculation whenever you need it, either as a
calculated field in a Query or just as you're now doing it -
in the control source of a Form or a Report textbox.

If, after reading this, they still insist on storing the redundant and
quite likely incorrect data, you will need to change the way you're
doing this on the form. Rather than setting the Control Source of the
textbox to the expression, set it to the name of the table field in
which the data should be stored, and "push" the value into the control
in the AfterUpdate events of EACH of the four other controls. Just use
an expression like

Me.txtTotal = Me.This + Me.That + Me.TheOther + Me.Whatever

You may also want to get a signed statement acknowleging that the data
in the Total field will be incorrect under some circumstances, and
that you cannot be liable for such errors.
 
Back
Top