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!

Suppressing group headers when not in repeated group header 2

Status
Not open for further replies.

GMcNamara

Programmer
Jun 24, 2002
235
0
0
US
I am using Crystal Reports 9. I have a single group in a report. I only want to show the group header if the group is continued from the previous page. My suppression condition is as follows: not(InRepeatedGroupHeader);

On the first page, it appears that a group is starting at the very bottom of the page, but nothing in the header appears because there is not enough room to display the entire header. Then the header is displaying on the next page, even though it didn't really appear on the page before. I have checked 'Keep Together' in the section expert for the group but this doesn't appear to be helping at all. The 'Keep Group Together' is not a good option because of the amount of white space it leaves in the report.
 
Hi,

If you only have one group, why are you grouping the report?
You can achieve the same order using sorting.

Can you not just suppress the text field if page_number = 1

Geoff
 
I'm assuming that you mean you have one group, with multiple instances of that group. Since group headers only appear at the beginning of a group or in repeated group headers, your suppression formula tells the report to suppress the header at the beginning of the group. Is this what you intend?

A repeated group header will only repeat if the group continues onto the next page, so if you want that to happen, and want the group header to print at the beginning of each group instance, then you do not need a suppression formula at all.

-LB
 
Try the following (it's rather involved):

1. Insert two new sections in your Details section, so you have a Details A, Details B, and Details C.

2. Details A should be your original Details section. Drag it down (click and drag in the gray area "Details A") so that it becomes Details C.

3. In Details B, place all the same fields, etc. that you have in your group header.

4. Create the following formulas:

Formula: InitRecordCounter
WhilePrintingRecords;
Global NumberVar RecordCounter := 0;

Formula: IncrementRecordCounter
WhilePrintingRecords;
global NumberVar RecordCounter;
RecordCounter := RecordCounter + 1

Formula: ResetRecordCounter
WhilePrintingRecords;
Global NumberVar RecordCounter := 0;

Formula: InitFirstPage
WhilePrintingRecords;
Global BooleanVar FirstPage := False

Formula: SetFirstPage
WhilePrintingRecords;
Global BooleanVar FirstPage;
If Not InRepeatedGroupHeader then FirstPage := True else FirstPage := False;
FirstPage

Formula: ShowFirstPage
WhilePrintingRecords;
Global BooleanVar FirstPage;
FirstPage


3. Place the formulas in the following sections
InitRecordCounter in GroupHeader1
IncrementRecordCounter in Details A
ResetRecordCounter in GroupFooter1
InitFirstPage in the ReportHeader
SetFirstPage in GroupHeader1
ShowFirstPage in Details A

4. Right-click on the formulas in Details A, choose Format Field and on the common tab suppress the display of the formulas.

5. In the section Expert, make the following changes:

a) On the main Details section (not Details A, B, or C) check the "Keep Together" option.

b) In Details A, check "Underlay Following Sections"

c) In Details B, add the following conditional formula to the "Suppress" option:

WhilePrintingRecords;
Global NumberVar RecordCounter;
If {@ShowFirstPage} = True then
True
Else
If RecordCounter <> 1 then
True
Else
False

d) Check the &quot;Suppress&quot; option for Group Header 1.

I can send you a report with saved data that shows these techniques in action. I think this meets your requirements.




 
FoxG,
This works but I want to show the group header if the group spills over onto the next page. I can't do that with just a detail section.

lbass,
I want the group header suppressed UNLESS it is in a repeated group header.

FVTrainer,
Wow, nice response. I still think there must be an easier way, as you said, your solution is rather involved. The report has 9 detail sections so your solution may work, but it will be quite a task to implement.

The question remains: Why is Crystal considering my group headers as repeated group headers when they are not being displayed on the first page?
 
OK, FoxG, I am going to be real honest here. At first I didn't really like your solution. But it seemed rather clever in it's simplicity. So, I played around with it and now it works correctly. I deleted my group and put the formula for the employee's name (which I was formerly grouping on) into the Page Header. Then I added the following suppression formula to the page header:

onfirstrecord or
not({@UserNameSort} = previous({@UserNameSort}));

This seems to work like a charm. I am still trying to break it but thanks again.
 
Exactly what I had in mind. Simple but effective!!

Geoff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top