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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grouping data in a subreport parent from subreport data

Status
Not open for further replies.

Zugdud

IS-IT--Management
Feb 26, 2003
158
US
Greetings, I have a subreport within a report and I would like to create a sub total for each customer. The report is already grouped by customer BUT the cost data I need to sub total is coming from a subreport! Is there a way to do this?
 
Which report is grouped by the customer, the Main?

Generally a short paragraph describing your problem is insufficient, were you to receive a spec like this you'd instantly contact the requestor, so this type of post will result in more questions because you don't bother to supply technical information (not even the version of your software, much less the database, etc.).

In general subreports are bad ideas, if you post the environment, someone might be able to meaningfully contribute to the overall architecture, rather than trying to supply technical information for a predesigned report.

You can use shared variables to pass data from subreports to main reports, example:

Main report Customer Group header formula:
whileprintingrecords;
shared numbervar MyNum:= 0

Customer linked Subreport formula:
whileprintingrecords;
shared numbervar MyNum:= sum(field);

Main report Customer Group footer formula:
whileprintingrecords;
shared numbervar MyNum

This will display a total from the subreport.

Hopefully this will get you on your way.

-k
 
Sorry about the lack of info, I am using Crystal 8.5 and fetching data from a progress 9.1D database via ODBC. You figured out the problem though, thats exactally what I am trying to do. And The code you posted seems to make logical sense, however I think we are doing the sum in the wrong place.

I need to make the sum at the end of the main group footer because it should be summing the subreport data. Ill try to attach some screen shots, sorry if im not making alot of sense

thankyou for the help!




 
The variable is being passed correctly from the subreport, I just need to figure out how to make a sum of it and also take into account that the formula seems to be a step AHEAD of the main report. Example, the variable is equal to the value of the previous row in each record so the total would not include the first and last value of each main group
 
So I guess what I need to figure out is how to do something like this in the main group footer:

whileprintingrecords;
shared numbervar MyNum:= sum(MyNum);

that doesnt seem to work however
 
Ok did some searching and got the totaling figured out for anyone else who is having a similiar issue:

In details section of each group I used this code:

whileprintingrecords;
shared numbervar MyNum;
numbervar grtot;
grtot := grtot + MyNum;

Then in group footer i used this code:

whileprintingrecords;
numbervar grtot;

the only problem im having now is that the total isnt taking into account the last record in each group
 
Ok whew, i finally just did a workaround and added a bogus record to eliminate the "one off" error

Anyway report is complete and fully functional, thanks again for all the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top