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!

New page before when a detail section last on page.

Jon_GM96

Programmer
Oct 17, 2024
1
Hi,

I have a report that looks like this.

Report Header
Detail a Text object 1
Detail b SubReport 1
Detail c SubReport 2
Detail d Text object 2
Detail e SubReport 3
Detail f SubReport 4
Detail g Text object 3
Detail h SubReport 5
Detail i SubReport 6
Report Footer


I want that if the Detail d or Detail g are the last section of a page they start on a new page.

Currently, when we print the report sometime we have this result.

Page 1:
Report Header
Detail a Text object 1
Detail b SubReport 1
Detail c SubReport 2
Detail d Text object 2

Page 2:

Detail e SubReport 3
Detail f SubReport 4
Detail g Text object 3
Detail h SubReport 5

Page 3:
Detail i SubReport 6
Report Footer

I want this if the subreport 3 doesn't fit on page 1

Page 1:
Report Header
Detail a Text object 1
Detail b SubReport 1
Detail c SubReport 2

Page 2:
Detail d Text object 2

Detail e SubReport 3
Detail f SubReport 4
Detail g Text object 3
Detail h SubReport 5

Page 3:
Detail i SubReport 6

I tried different things with "keep together" settings but nothing works.

Thanks
 
Unfortunately, Crystal won't know if you're close to the end of a page to be able to do this. You could turn on "New Page Before" for Detail d and Detail g and always have a page break before or you might be able to simulate a group using a global variable and have Detail section a, d, and g be group header sections. Here's how that might work:

1. Create a formula to initialize a global numbervar that I'll call "grouping":
{@InitGroup}
Global Numbervar grouping := 1;
""
Put this in the report header. The final empty string in the formula makes it so that it doesn't display anything.

2. Create a formula to use the value of grouping:
{@Grouping}
Global Numbervar grouping
Create a group on this formula and make sure that "Keep Group Together" is turned on.

3. Create 3 group header sections for this group - GH1a will have the text from what was Details a, GH1b will have the Details d text, and GH1c with have the Details g text.

4. In the Section Expert, set the Suppress formula for the three group header sections. DO NOT check the Suppress checkboxes! Here's the formulas:
GH1a: {@Grouping} > 1
GH1b: {@Grouping} <> 2
GH1c: {@Grouping} < 3
This will set it so that the sections only show when you want them to. You'll use the same formulas to suppress the Details sections for each "group".

5. Delete Details a, d, and g since you've moved the text to the group headers.

6. In the second subreport for groups 1 and 2, you'll add a formula similar to the formula in Step 1 above to the group footer section - in Subreport 2 it will set the grouping variable to 2 and in Subreport 4, it will set the grouping variable to 3.

7. Set the suppress formulas for BOTH the Details section AND the subreports they contain based on whether they're in group 1, 2, or 3.

8. Make sure that "Keep Together" is turned on for each subreport and for each section that a subreport is in.

With the suppress formulas set correctly on the details sections, you should see the following:

Report Header
Group 1 Header A - Text
Details a - Subreport 1
Details b - Subreport 2
Group 1 Header B - Text
Details c - Subreport 3
Details d - Subreport 4
Group 1 Header C - Text
Details e - Subreport 5
Details f - Subreport 8

-Dell
 
Last edited:

Part and Inventory Search

Sponsor

Back
Top