Calculation Question

L

Lori

Hello, I have a form "Property Management" with a field "total property sqft"
and a subform "Units". In the "Units" form is a field "square footage".
What I would like to happen is once the Units square footage is entered for
the Property Management field "total property sq ft" to add those unit
amounts. Property Management and Units are two seperate tables. Can anyone
assist me with this?
 
A

Allen Browne

Hi Lori

The best idea would probably be to drop the total property sqft from the
Property Management table, and just use the sum of the floor space of the
units in the property. That's the only way you can be certain that the
database is consistent.

The only valid reason for storing the total would be if the total should
sometimes be *different* from the sum of the individual units. If that is
the case, you probably don't want the database overwriting the total floor
space as you enter units into the subform.

If you want to do it anyway, use the AfterUpdate event of the subform
control to DSum() the square footage of the units in the building. Do this
directly on the subform's table rather than relying on a calculated control
on the subform in case the subform is filtered (and because the calculated
control won't be updated in time). Then write the result to the parent form,
and save the change. Do the same in the AfterDelConfirm event of the subform
so the change is made when you delete a subform entry as well.
 
Top