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

Keep Group Together, except... 7

Status
Not open for further replies.

ChristianWhite

Programmer
Jun 14, 2004
41
0
0
US
I often see group headers printed as the last line on my pages. I would like these groups instead to start on the next page--"Keep group together" seems best.

Problem, though: I expect the user would prefer to have a fairly compact report. If I use Keep Group Together, then I'll often get a page with only one short group, the rest of the page blank because a big group starts on the next page.

Is there an option that would ensure a group header wouldn't occupy the last line on a page, yet in other cases, group B would always start right after group A?

"Repeat group header on each page" would be a valid choice--if I knew how to get rid of that last-line-on-the-page group header that sometimes prints.
 
Do you know your version of Crystal?

If you right click the group and select change group, you can choose the keep group together in there, and repeat group header on each page, which may do what you're after, hard to say.

-k
 
You could create two formulas:

//{@reset} to be placed in the page header:
whileprintingrecords;
numbervar linecnt := 0;

//{@linecnt}:
whileprintingrecords;
numbervar linecnt := linecnt + 1;

Place {@linecnt} in every group or detail section displayed on the page, e.g., GH1,GH2, details, GF2, GF1. In design view, make sure the height of each section is exactly the same, using a magnified view, so that the line count is the same for each page (Ideally you would suppress the report header or format it to "new page after" so the next page has the correct line count.).

Then go to the section expert (format->section)->GH1->New Page Before->x+2 and enter:

whileprintingrecords;
numbervar linecnt = 55;

Change "55" to the number of the last line on your page.

If you have multiple groups, you could use the above formula for GH#2, and for GH#1, use:

whileprintingrecords;
numbervar linecnt in [54,55];

This way the "fix" for GH#2 would not cause an orphaned GH#1.

-LB

 
I was able to accomplish your goal this way:

Create a Running Total field. Set it up to summarize a field in your details, summary type should be Count, Evaluate each Record, and Reset on change of your Grouping. Place somewhere in your details section.

Change your Group to only "Repeat Group Header on Each Page", and not "Keep group Together".

Insert another Group Header section. You should now have a Group Header A and a Group Header B. Copy all your detail fields, and paste them into Group Header B so that they line up with the fields in the detail section.

Next, go to Report, Section Expert.
Highlight Group Header (not A or B, but the parent one above A) and select the property "Keep Together".
Next, highlight Group Header B, and click the X+2 button next to Suppress (No Drill Down).
Enter the following line into the editor:

inrepeatedgroupheader

Click Save and Close.
Next, highlight Details and click the X+2 button next to Suppress (No Drill Down).
Enter the following line into the editor:

{#RTRowCount} = 1 //modify with your RT field

Click Save and Close.

You can suppress the RT field(s) on the report if you want, I just left them there for validation purposes.



~Brian
 
I am running into the same issue. Brian's suggestion is awesome, except that my details section has two columns (formatted with multiple columns), and as far as I know, there is no way to have multiple columns in the group header. This means that the first cell in the right column is blank for every new group. Any thought on how to fix this?

Thanks!
mp
 
Just what I needed Brian. Thanks.

zemp
 
Just what I also need. I did find a small problem but it was resolved quickly and it works great.

The small problem was that we use detail shading on alternate details. Now with that new group header, it created two detail lines that are not shaded. I copied the code for shading in Color tab for the detail and pasted it in the same place for the new group header. It works.
 
I have the same problem but I have 4 levels of group so I can't put the details in the Group Header B. Any ideas? What I need is a Keep With Next command
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top