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

Dynamically use counts from subreport for new page calc. 1

Status
Not open for further replies.

tradle

Programmer
Jan 7, 2004
94
0
0
US
Hi All -

I'm trying to write logic that sums a total from one subreport with a dynamic total from another subreport, and then format the details of the main page to go to a new page when the sum of the totals = 29. The issue is that I can see the dynamic count happening at the second subreport level, but don't know how to use the dynamic total at the main report.

The layout of the whole mess is like this:

Page Header
Group Header 1 (where the first subreport is)
Details (where the second subreport is)
etc...

In the first subreport, I generate a sum total of all rows generated and pass the value with the following:

Whileprintingrecords;
Shared Numbervar stock_count:=(Count ({column}));

In the second subreport, I create a variable to store a count and default it to 0 in the page header of the subreport, and add one to the count with each line printed in the details of the subreport. The formulas for both are:

Whileprintingrecords;
Shared Numbervar fund_count := 0;

Whileprintingrecords;
Shared Numbervar fund_count;
fund_count := fund_count + 1;

What I'm trying to do is create the logic where (in the main report) after the first subreport fires and during the process of the second subreport, a new page is started when:

stock_count + fund_count := 29

The thing is, I don't know how to create the logic to interact dynamically with the second subreport from the main report as it is being printed. In other words, I can grab a total without issue after the subreport finishes printing, but by that time, it's too late.

If I can provide any other points that may help to describe the issue and assopciated components, please let me know. I'd sure appreciate any help that can be offered.

Thanks,
Tim
 
It helps to give your Crystal version, since newer versions have extra options, and some extra problems.

I use Crystal 8.5, which doesn't allow anything to be done to a section with a subreport on the basis of a value the subreport will return. You only have that value in the next section.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
The standard work-round is to do a subreport twice, the first time reduced to near-invisibly. Does this help?

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Sorry - I'm using Crystal 9.0. Thanks Madawc.
 
Madawc -

Could you explain a bit more what you mean? If I were to run the subreport twice, what behaviors/variables would I look to set the first time around versus the second?

Thanks,
Tim
 
If you put the first (hidden) copy in a higher section, you will already have the returned value when you come to run it again. You can use it then to decide something about printing - usually to suppress, but a new page should work.

Right-click on the detail section and choose Format Section. Then choose the formula icon (x+2 and a pencil) for suppression, new page or whatever. Enter a formula to decide when the specified action should happen.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Madawc,

Thanks for your suggestion! That solves one problem. Would you mind weighing in on another?

Whenever the subreport that populates the detail section contains more rows than can fit on a page, the entire subreport populates on another page. In other words, page shows the page and group header data, but then cuts to another page and displays the detail setion on down. I've tried unckecking "Keep Together" and thus far have not found a solution. Can you think of anyplace that would set this kind of behavior?

Thanks,
Tim
 
Go to format subreport->common and uncheck "Keep object together".

-LB
 
lbass -

THANK YOU!!!!!!!!!!!!!!!!!!!

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top