Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding the total fields from two subreports

Status
Not open for further replies.

ije

MIS
Jun 10, 2002
38
0
0
AU
hello,

I have a report ( CRD 8)that has two subreports, which are connected vai leftouter joins to the main report table. Each subreport adds up some numbers and totals them, and I can display the total for each subreport OK. However,in the report footer, I wish to add up the two different subreport totals. I wish the report to resemble:
Header
DetailA
detailB - Subreport1 - total1
DetailC - Subreport2 - total2
Report Footer - total 1 + total2

What happens is that for how ever many records are added up in the subreports, the details of the report is repeated. So if there are 3 records found related to the main table, then I get:

Header
DetailA
detailB - Subreport1 - total1
DetailC - Subreport2 - total2
DetailA
detailB - Subreport1 - total1
DetailC - Subreport2 - total2
DetailA
detailB - Subreport1 - total1
DetailC - Subreport2 - total2
Report Footer - total 1 + total2

Can anyone shed some light on what I doing wrong? I am using the following in my Footer Total field, which I where I think I doing it wrong - {@JournalTimeSpentJoursCost} + {@Parts Costs}

Help really appreciated!!!
ije
 
Subreports are linked to a main report via subreport links. I'm not sure what you mean by "...subreports, which are connected via left outer joins to the main report table." But if you used the visual linking expert to link not only to the tables used in the main report (if there is more than 1) to the table(s) used by the subreport and then created separate subreports to bring in the data from those tables, I think you misunderstand how data queries work in Crystal.

The main report should only include joins to tables that are required by the main report. For example, if you have a main report that collects data from tables A and B, we'd expect that you'd have a join between these two tables. Crystal will run the query to collect data for the main report based on the tables and joins defined in the visual linking expert.

If you then add a subreport that uses table C, table C would not appear at all in the visual linking expert in the main report. Instead, you'd create your subreport using table C as it's datasource, and then, if the subreport runs based on a value in the main report, you link the field that contains that value in the main report to the corresponding field in the subreport. But you do not add Table C to the main report. When the subreport runs, it, too, queries the database, but using the table(s) contained in the visual linking expert for the subreport only.

The fact that you are getting more records than you expect indicates that your join is incorrect. By the way, does your main report only return 1 record? It's rather unusual for a subreport to be placed in the details section. Do you truly need a subreport or would joins be sufficient to collect the data you need?
 
It's a little hard to tell, but I'm guessing that you want a set of details (your detail_a) followed by two other sets of details. If you have no groups, try inserting two additional report footer sections and place the subreports in report footer_a and report_footer_b, followed by the totals in report footer_c. If you have groups, use additional group footers for the subreport placements.

I can't tell whether your total formula will work, since you do not relate them to the other information or share the contents of the formula, but be sure to create the formulas contributing to the total as shared variables within the subreports and then reference them as shared variables in the main report.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top