Adding two subreport totals? (1 Viewer)

fletchee2003

Registered User.
Local time
Today, 00:35
Joined
Apr 21, 2005
Messages
31
This would be a piece of cake if it was excel, but I just not sure of the proper language to get what I want. I have one report that has two subreports embedded. Each subreport has a subtotal, I need to add those to get a grand total for the report. I need subreport1 total (7.5) to be added to subreport2 total (3.0) to get a grand total (10.5). Any suggestions would be very helpful. Thank you.
 

boblarson

Smeghead
Local time
Yesterday, 22:35
Joined
Jan 12, 2001
Messages
32,059
1. Put a text box in the FORM FOOTER of EACH of the subforms (it is okay if you are using it in Datasheet mode as we don't need to see it, just refer to it).

2. Put the control source of the text box as
=Sum([YourFieldToSumHere])
(making sure you don't have controls named the same as your field names).

3. Put in a TextBox on your main form and use:
Code:
=YourSubForm1CONTAINERNameHere.Form!YourTextBoxNameInSubForm1Footer + YourSubForm2CONTAINERNameHere.Form!YourTextBoxNameInSubForm2Footer
 

fletchee2003

Registered User.
Local time
Today, 00:35
Joined
Apr 21, 2005
Messages
31
Confused..

what is 'YourSubForm1CONTAINERNameHere'? Where do i find that?
 

boblarson

Smeghead
Local time
Yesterday, 22:35
Joined
Jan 12, 2001
Messages
32,059
The subform container is the part that LOOKS like it is the subform on the main form when in design mode. It actually houses the subform. A lot of the time the subform container name is the same as the subform, but when you add the subform onto the main form, the wizard will give you the option to name the control and, if you name it something other than the subform name, you have to refer to it instead of the subform name itself.

Does that make sense?
 

fletchee2003

Registered User.
Local time
Today, 00:35
Joined
Apr 21, 2005
Messages
31
Hmmm.

I think I know what you are talking about. I selected the text box that houses subreport1 and then clicked on the properties button to find the source name. Would that be the same? I have a slimmed down version of the database that I could send to you, it is to big to post here. (1.3 mb). Thank you for the help.
 
R

Rich

Guest
Use the HasData method, there have been many examples posted here
 

boblarson

Smeghead
Local time
Yesterday, 22:35
Joined
Jan 12, 2001
Messages
32,059
I think I know what you are talking about. I selected the text box that houses subreport1 and then clicked on the properties button to find the source name. Would that be the same? I have a slimmed down version of the database that I could send to you, it is to big to post here. (1.3 mb). Thank you for the help.

I'll PM you one of my email address.
 

boblarson

Smeghead
Local time
Yesterday, 22:35
Joined
Jan 12, 2001
Messages
32,059
I have a slimmed down version of the database that I could send to you, it is to big to post here. (1.3 mb). Thank you for the help.

I don't know but you probably didn't compact and repair before zipping and checking the file size because I just zipped it (AFTER running Tools > Database Utilities > Compact and Repair) and it came out to 46KB instead of 1.3Mb.

Anyway, I made the changes to get the totals. I put the stuff I changed in Red so it was easy to spot. You should also look in design mode at the subforms to see the form footers.
 

Attachments

  • Test1_revised07-21-2007.zip
    45.6 KB · Views: 153

fletchee2003

Registered User.
Local time
Today, 00:35
Joined
Apr 21, 2005
Messages
31
I see where you made the changes and its awesome. On the report titled "LMS_Student_Table" how can I get it to add the totals from the two subreports? I tried to mirror what you did, but I may be missing a step. If you have a free minute, can you help me out again? Thanks,
 

boblarson

Smeghead
Local time
Yesterday, 22:35
Joined
Jan 12, 2001
Messages
32,059
Put a text box on your report in the details section and set the controlsource to:

=[IDP Hours].Report!Text14+[Non_IDP Table].Report!Text18

But, I would highly suggest renaming your Text boxes on the sub reports to something meaningful and then modifying this code to reflect your name changes (it is easier for maintenance when you come back to it months, or years, later).
 

fletchee2003

Registered User.
Local time
Today, 00:35
Joined
Apr 21, 2005
Messages
31
Oh happy day...

I see that I have much to learn from you! Thank you so much.
 

Users who are viewing this thread

Top Bottom