Bound control to sum fields

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
 
M

Marshall Barton

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.
 

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