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

Keep subreports together

Status
Not open for further replies.

cspuckett

IS-IT--Management
Feb 6, 2009
27
US
I had a post yesterday where I have two report footer subreports that I wanted to appear back-to-back vertically. I got the tip of splitting them into their own report footers (i.e., RF_a and RF_b).

Now, in a few scenarios, I have a new situation to address. It occurs when subreport2 is more than a page long. In that scenario, subreport2 begins on a new page. I'd like to have it always start right after subreport1 finishes (unless that's at the bottom of the page). But in this scenario, subreport1 is finished in the top 10% of the page, then the rest is blank, and subreport2 starts on page 2 and goes for a couple pages.

I have tried all the "Keep Together" options and checked for rogue "New Page Before (or After) Settings" and nothing seems to work.

Any thoughts on how to always keep subreport2, in RF_b, to always be right after subreport1, in RF_a (ideally with added logic to account for a certain location where it would kick to a new page...i.e., even if subreport2 could start at the bottom but only print 2 lines, then I might as well have it all simply start on the next page).
 
Select subreport#2->right click->format subreport->common tab->uncheck "Keep Object Together".

-LB
 
LB,

Once again you came to the rescue. I thought I had tried that one, but must not have. That worked.

What would be the best conditional (and where, presumably under Paging of RF_b) to put logic that when subreport1 ends at line x (say 45), that subreport2 while start on a new page?
 
In subreport 1, you would have to create a counter to place in the detail section and/or other sections:

whileprintingrecords;
shared numbervar cnt := cnt + 1;

Then in the main report->section expert->report footer_b->new page before->x+2:

whileprintingrecords;
shared numbervar cnt;
cnt >= 45

-LB
 
Okay, that makes sense. However, subreport1 could start on line 5 of page 2 or line 20 of page 6...just depends on the detail in the Main report.

So, it seems like I also need a counter in the Main report (detail section). Which leads to two questions:

1. Can I use the same variable (cnt) for both and Crystal will do an accurate count? For example, detail ends on line 5, so cnt = 5...and then the count simply continues with the detail in subreport2, such that if it has 10 lines, cnt = 15, correct?

2. While I can probably figure the line break logic depending on page number (i.e., if page 1, break when cnt > 45, if page 2, break when cnt > 95, if page 3, break when cnt > 145...). But that does not seem smart. What's a better way to either start the count over on each page of the Main report and/or only begin the count when on the last page of the Main report?
 
UPDATE:

Through some trial and error, I think I have a good "new page before" logic.

I did use the same "cnt" variable through out the main and subreport1 and the counter keeps increasing (which is what I wanted).

I like the break when I use:
cnt - (50 * (PageNumber - 1)) >= 35

Might make one final tweak to not break if subreport2 is only 2-3 lines (which I can do with a separate counter).
 
The problem is that values in the subreport cannot be shared until after the sub completely executes, so you won't be able to reset easily per page. It might make sense to decide that the sub1 always starts on a new page.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top