Subform problem

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

Guest

I have a value on a main form. I then have a subform with 5-10 records tied to the main form. I want to take the sum of the dollar values in the subform and divide that sum by the one value on the main form. I have tried the after update event of the suform but it always seems to be one calculation behind. In other words
Main form $1

Sub form $
$
$

Sum of subform =$

Calculation on the main form should be 4/10 = 40

if I change record 2 to $3 instead of $2 the calculation in the main form stays at 40%. If I then change it again to 4$ instead of $3 the calculation goes to 50% which should have been the calculation when record 2 was $3. Any help would be appreciated.
 
A great example is in the Northwind database that comes
with Access. Check the Orders Form.


Short answer is to put a field in the form footer of the
subform that's controlsource is =Sum([FieldToBeSummed]).
Name it SubTotal, and set the visible property to false.

On the Main form, have a box that has it's controlsource
to =SubFormName.Form.SubTotal


Chris

-----Original Message-----
I have a value on a main form. I then have a subform with
5-10 records tied to the main form. I want to take the sum
of the dollar values in the subform and divide that sum by
the one value on the main form. I have tried the after
update event of the suform but it always seems to be one
calculation behind. In other words:
Main form $10

Sub form $1
$2
$1

Sum of subform =$4

Calculation on the main form should be 4/10 = 40%

if I change record 2 to $3 instead of $2 the calculation
in the main form stays at 40%. If I then change it again
to 4$ instead of $3 the calculation goes to 50% which
should have been the calculation when record 2 was $3. Any
help would be appreciated.
 
Back
Top