Calculations between forms

J

Jamie

I have a form with a subform attached. I am trying to get the quantities
from the subform to total so i can use them in a calculation in the primary
form.
 
A

Allen Browne

Place a text box in the Form Footer section of the subform.
Set its Control Source to sum the field you want, e.g.:
=Sum([Qty])

If the subform is in Form or Continuous view, you can see the total. In
Datasheet view you can't (though there is a way in Access 2007), so you will
need a text box on the main form to display the total. Its Control Source
will be like this:
=[Sub1].[Form]![Text0]
where you use your subform control name instead of Sub1, and the name of the
text box created above instead of Text0. The .Form bit stays as it, as
explained here:
http://allenbrowne.com/casu-04.html

For an example of such a form, look at the Orders form in the Northwind
sample database.

There is an extra wrinkle if new records cannot be added to the subform. Its
Detail section goes completely blank when there are no records to show, and
the expressions error out. Post back if you hit this.
 

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