Bound control to sum fields

  • Thread starter Thread starter slythe39
  • Start date Start date
S

slythe39

Hello,

I need to make a control that takes the sum of other text boxes on a
form and enters it into a field in the database. I can make an
unbound control that sums the fields (e.g. [field1]+[field2]+...) and
displays it to the user, but I need the data to actually stay in the
record. The problem here is that I put the sum formula in as the
control source, which prevents me from having a field as the control
source.

How can I make a bound control that automatically takes the sum of
other controls on the form?

Thanks,
Craig
 
I need to make a control that takes the sum of other text boxes on a
form and enters it into a field in the database. I can make an
unbound control that sums the fields (e.g. [field1]+[field2]+...) and
displays it to the user, but I need the data to actually stay in the
record. The problem here is that I put the sum formula in as the
control source, which prevents me from having a field as the control
source.

How can I make a bound control that automatically takes the sum of
other controls on the form?


The minimum you need to do is use VBA code in the
AfterUpdate event of every text box involved in the
expression. BUT even then there is no way to guarantee that
the toal will always be accurate. Because of the lack of a
guarantee, saving a derived value is an absolute NO-NO in a
relational database. Instead you shoud recalculate the
total from the other fields whenever you need to display or
use the total.
 
Back
Top