views:

72

answers:

1

I have a report that groups by two codes, we'll call them Parent and Child.

At the top of each page, in the Page Header, I want to print the Parent Name.

There are a number of columns in the report, and when the group breaks, I want to display the new Child name, as well as the column headers again. The report should look something like this:

Parent Name
    Child Name
    Col1 Col2 Col3 Col4 Col5 Col6
    XXXX XXXX XXXX XXXX XXXX XXXX
    XXXX XXXX XXXX XXXX XXXX XXXX

    Child Total:             XXXX

    Child Name
    Col1 Col2 Col3 Col4 Col5 Col6
    XXXX XXXX XXXX XXXX XXXX XXXX

If a child group wraps around to the new page, though, I want to re-display the Child Name and column captions before displaying data again.

To accomplish this, I have created a Page Header that contains the following objects:

Parent Name
    Child Name
    Col1 Col2 Col3 Col4 Col5 Col6

In the page header is a variable RowReset that contains the following formula:

WhilePrintingRecords;
Shared numberVar nRowCount := 0

Then, in each detail row, as well as the Group Footer 1 and Group Footer 2 sections, I have the following RowIncrement formula:

WhilePrintingRecords;
Shared numberVar nRowCount := nRowCount + 1;

Finally, in each Group Header 2 section, I have the following conditional suppression formula:

WhilePrintingRecords;
Shared numberVar nRowCount;
IF (PageNumber <> 1) AND (nRowCount = 0 OR nRowCount = 0.00) THEN
    True
ELSE
    False

What this attempts to do is suppress the Child group header if we're on a brand new page, and no detail records have been printed yet, to prevent the following from happening:

Parent Name                          ---+
    Child Name                          +-- Page header
    Col1 Col2 Col3 Col4 Col5 Col6    ---+

    Child Name                       ---+-- Group header 2
    Col1 Col2 Col3 Col4 Col5 Col6    ---+

For some reason I can't figure out, about 40 pages into the report, I get exactly that though; a Page Header record, followed by a Group header 2 record. If I create a formula that contains the conditional suppress formula, it displays TRUE, but the group header still doesn't suppress.

If I break up the code so that it checks only one of the conditionals (either PageNumber <> 1 or nRowCount = 0) then the Group Header 2 suppresses correctly.

I have even tried this to break things up:

WhilePrintingRecords;
Shared numberVar nRowCount;
booleanVar bSuppress:= False;

IF PageNumber <> 1 THEN bSuppress:= True;
IF (bSuppress) THEN (IF nRowCount = 0 THEN True ELSE False);

It also displays True when displayed on the screen, but fails to suppress the group header.

What on earth am I doing wrong here? Is there a better approach I could take?

+2  A: 

I suggest putting the 'parent name' field in the group header of its own group, rather than in the page header. Then, in both the parent and child groups, select the "Repeat Group Header On Each Page' check box in the group options dialog box.

Ray
You know, that's really embarassing -- somehow I have *never* noticed that checkbox in the Group Options dialog. I was looking for something like that in the Format Group options. It still doesn't explain why the code didn't work, but I'm just happy to move on. Thanks!
LittleBobbyTables
I'm glad it worked for you. I have used variables like you were doing in some cases where the built-in properties didn't quite cut it, and it is always a nightmare to get it working properly.
Ray