totaling columns from a subform onto the parent form

T

tecas

How do I accomplish totaling a column from a subform onto a text field
in the parent form?
 
G

Graham Mandeno

Hi Ted

Create a textbox in the header or footer of your subform, with its
ControlSource set to:
=Sum([MyField])
Set its Visible property to "No" and give it a meaningful name (eg
"txtTotalSales")

Now, with the textbox on the parent form, set its ControlSource to:
=[Name of subform control].Form![txtTotalSales]
 
J

John W. Vinson

How do I accomplish totaling a column from a subform onto a text field
in the parent form?

Use a relay: put a textbox in the Subform's header or footer (which need not
be visible, but must be there). Set its Control Source to

=Sum([fieldname])

to sum the value of a field in the subform's Recordsource. Note that this must
be a field in the Table or Query - not a control name on the form.

Name this control something meaningful, such as txtTotal.

Then on the mainform put another textbox with a control source

=subformname.Form![txtTotal]

where subformname is the Name of the *subform control* - which might or might
not be the same as the name of the Form within that control.

Note that you should almost certainly *not* store this total in any Table
field - just display it, and recalculate the total whenever it's needed.

John W. Vinson [MVP]
 
T

tecas

Hi Ted

Create a textbox in the header or footer of your subform, with its
ControlSource set to:
=Sum([MyField])
Set its Visible property to "No" and give it a meaningful name (eg
"txtTotalSales")

Now, with the textbox on the parent form, set its ControlSource to:
=[Name of subform control].Form![txtTotalSales]
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand




How do I accomplish totaling a column from a subform onto a text field
in the parent form?- Hide quoted text -

- Show quoted text -

Thanks Graham, worked like a charm
 
T

tecas

How do I accomplish totaling a column from a subform onto a text field
in the parent form?

Use a relay: put a textbox in the Subform's header or footer (which need not
be visible, but must be there). Set its Control Source to

=Sum([fieldname])

to sum the value of a field in the subform's Recordsource. Note that this must
be a field in the Table or Query - not a control name on the form.

Name this control something meaningful, such as txtTotal.

Then on the mainform put another textbox with a control source

=subformname.Form![txtTotal]

where subformname is the Name of the *subform control* - which might or might
not be the same as the name of the Form within that control.

Note that you should almost certainly *not* store this total in any Table
field - just display it, and recalculate the total whenever it's needed.

John W. Vinson [MVP]

Thanks for the response, John. Both yours and Grahams are the same and
worked
 

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