Calculating a total in a Subform and displaying it in the Master f

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

Guest

I have a subform within a form where I calculated the sum of a field. I need
to show that result in the main form. How can I do that? I created a text
box to display the sum([approved cap]). When it's display on the subform it
showing the result on every record. But I only want to display the result
once. When I try to move the text box into the main form and I get an #error
message. Thank you for your help!
 
Yvette said:
I have a subform within a form where I calculated the sum of a field. I need
to show that result in the main form. How can I do that? I created a text
box to display the sum([approved cap]). When it's display on the subform it
showing the result on every record. But I only want to display the result
once. When I try to move the text box into the main form and I get an #error
message.


You should put the Sum text box in the subform's header or
footer section, not in the detail section.

If you also want to display that total on the main form as
well, then add a text box to the main form (detail section?)
that refers back to the Sum text box in the subform. E.g.
the main form text box expression would be something like:
=subformcontrolname.Form.sumtextboxname
 
Thank you Marshall. I put the sum box in the subform's header but I am only
able to see it when the subform is in single form view. The drawback to that
is that I cannot see the records one right after each other like a datasheet
view even after aligning all the text boxes to look like a datasheet. I
also tried your suggestion of displaying a sum on the main form but I
continue to get a #Name? error. Any more suggestions...I appreciate your
help and time. Thank you again.

Marshall Barton said:
Yvette said:
I have a subform within a form where I calculated the sum of a field. I need
to show that result in the main form. How can I do that? I created a text
box to display the sum([approved cap]). When it's display on the subform it
showing the result on every record. But I only want to display the result
once. When I try to move the text box into the main form and I get an #error
message.


You should put the Sum text box in the subform's header or
footer section, not in the detail section.

If you also want to display that total on the main form as
well, then add a text box to the main form (detail section?)
that refers back to the Sum text box in the subform. E.g.
the main form text box expression would be something like:
=subformcontrolname.Form.sumtextboxname
 
Datasheet view is rather limited and I much prefer
Continuous view. Maybe this is all you need.

If you really need the total on the main form, then check
each name used in the expression to make sure they are
refering to the correct object and are spelled correctly.
--
Marsh
MVP [MS Access]

Thank you Marshall. I put the sum box in the subform's header but I am only
able to see it when the subform is in single form view. The drawback to that
is that I cannot see the records one right after each other like a datasheet
view even after aligning all the text boxes to look like a datasheet. I
also tried your suggestion of displaying a sum on the main form but I
continue to get a #Name? error.

Yvette said:
I have a subform within a form where I calculated the sum of a field. I need
to show that result in the main form. How can I do that? I created a text
box to display the sum([approved cap]). When it's display on the subform it
showing the result on every record. But I only want to display the result
once. When I try to move the text box into the main form and I get an #error
message.
Marshall Barton said:
You should put the Sum text box in the subform's header or
footer section, not in the detail section.

If you also want to display that total on the main form as
well, then add a text box to the main form (detail section?)
that refers back to the Sum text box in the subform. E.g.
the main form text box expression would be something like:
=subformcontrolname.Form.sumtextboxname
 
Thank you Marshall. You were absolutely right. I was referencing the wrong
name on the main form. Now it works! You've been a great help to me.
Have a great weekend! : )
Yvette

Marshall Barton said:
Datasheet view is rather limited and I much prefer
Continuous view. Maybe this is all you need.

If you really need the total on the main form, then check
each name used in the expression to make sure they are
refering to the correct object and are spelled correctly.
--
Marsh
MVP [MS Access]

Thank you Marshall. I put the sum box in the subform's header but I am only
able to see it when the subform is in single form view. The drawback to that
is that I cannot see the records one right after each other like a datasheet
view even after aligning all the text boxes to look like a datasheet. I
also tried your suggestion of displaying a sum on the main form but I
continue to get a #Name? error.

Yvette wrote:
I have a subform within a form where I calculated the sum of a field. I need
to show that result in the main form. How can I do that? I created a text
box to display the sum([approved cap]). When it's display on the subform it
showing the result on every record. But I only want to display the result
once. When I try to move the text box into the main form and I get an #error
message.
Marshall Barton said:
You should put the Sum text box in the subform's header or
footer section, not in the detail section.

If you also want to display that total on the main form as
well, then add a text box to the main form (detail section?)
that refers back to the Sum text box in the subform. E.g.
the main form text box expression would be something like:
=subformcontrolname.Form.sumtextboxname
 
Datasheet view is rather limited and I much prefer
Continuous view. Maybe this is all you need.

If you really need the total on the main form, then check
each name used in the expression to make sure they are
refering to the correct object and are spelled correctly.

So is this not possible then using Datasheet view?

IE: Can you place a 'total' on the 'Main' form that is getting it's sum from
the 'SubForm' and you are using Datasheet view on the 'subform'?

Just so happens I was looking at trying to put a total on my main form and
saw this thread. From reading the thread, Yvette got the display of a total
on the main form, but to do so the view was changed to Single Form view. I
really do like my Datasheet view. :-)

Tim
 
Tim said:
in message

So is this not possible then using Datasheet view?

IE: Can you place a 'total' on the 'Main' form that is getting it's sum from
the 'SubForm' and you are using Datasheet view on the 'subform'?

Just so happens I was looking at trying to put a total on my main form and
saw this thread. From reading the thread, Yvette got the display of a total
on the main form, but to do so the view was changed to Single Form view. I
really do like my Datasheet view. :-)


It think you misunderstood the instructions to Yvette.

You can use a datasheet subform and do the calculations in
the subform's header/footer section. You just can't see the
subform's header/footer except in design view. That's why
she has to reference it from a main form text box so the
total can be dispslayed.
 
It think you misunderstood the instructions to Yvette.

You can use a datasheet subform and do the calculations in
the subform's header/footer section. You just can't see the
subform's header/footer except in design view. That's why
she has to reference it from a main form text box so the
total can be dispslayed.

Marsh,

Yep, I did misunderstand how that was being used. I went into the design
view for the subform and added the control to give a subtotal. Then went
into the main form and referenced this new control. BAM! It works
perfectly.

Now all of my purchase orders have a total now of how much the order will
come to.

Tim
 
Back
Top