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

Compare data between main report and subreport 1

Status
Not open for further replies.

sangisiva

Programmer
Apr 7, 2008
44
IN
Hi All,

I am working in a report within there is a subreport.Subreport is placed in the group footer.

I am stuck where I need to compare the data between both the reports.

For eg.
Main report contains

ID Name
10 aa
10 aa
20 bb
30 cc
30 cc


Sub Report

ID Name
10 aa
30 cc
30 cc
40 dd
50 dd


I have to get the distint count of ID for each of the report and as well for overall distinctcount for both the report together.

I can achieve each report's count using distinctcount

Main report - 10,20,30 - 3
Sub Report - 10,30,40,50 - 4


Overall - 10,20,30,40,50 - 5
----> I do not know how do i compare the ID's between two subreport. Is there a way to do this ?
 
You can pass data back using Shared Variables - use Search for the method. Or you can pass values down using Edit > Subreport Links and make the comparison in the subreport.

Neither method is very convenient for compairing large amounts of data. Maybe you need to rethink the method.

It helps to give your Crystal version - 8, 8.5, 9, 10, 11 or whatever. Methods sometimes change between versions, and higher versions have extra options.



[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
What field are you grouping on? What field(s) are you using to link the sub to the main report?

-LB
 
Hi,

Thanks for the reply.
I am using CR10.

I am comparing the ID field. I am grouping the data based on country field which is not mentioned earlier.

Thanks in advance.

 
I linked the subreport with the main report using parameters and the grouping field.
 
Create these formulas:

//{@resetmain} to be placed in the country group header:
whileprintingrecords;
shared stringvar main;
if not inrepeatedgroupheader then
main := "";

//{@accummain}-Place this formula in the detail section of the main report:
whileprintingrecords;
shared stringvar main;
if instr(main,totext({table.ID},"00")) = 0 then
main := main + totext({table.ID},"00")+",";

In the subreport, add this formula to the detail section:
whileprintingrecords;
shared stringvar sub;
shared stringvar main;
if instr(main, totext({table.ID},"00")) = 0 and
instr(sub,totext({table.ID},"00")) = 0 then
sub := sub + totext({table.ID},"00")+",";

Place this formula in the sub report footer:
whileprintingrecords;
shared stringvar sub;

Then in the main report GF1b, add this formula:
whileprintingrecords;
shared stringvar sub;
shared stringvar main;
ubound(split(sub,",")+ubound(split(main,",")-2;

This should be close. Didn't have time to test.

-LB
 
Hi lbass,

Thanks for the reply. Will try out the same and let you know.

 
Hi lbass,


I used the same logic. It worked perfectly.

Thank you.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top