Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Group Header Labels

edited January 2004 in General
Hi All,

I'm trying to set a label caption in the group header depending on the
value of the group break value. For instance, if I have a boolean
field called "cool" as the group break value, I want the label to read
"This is cool" for True or "This ain't cool" for false.

I've tried setting this in the group header's OnBeforeGenerate and
OnBeforePrint events and, in both cases, the only change that prints
is the last one set. For instance, when the page displays, I get:

This Ain't cool

Cool = True


This Ain't cool

Cool = True


This Ain't cool

Cool = False

How do I get the label to display the correct caption depending on the
break value?

Thanks,
Steve

Comments

  • edited January 2004
    Hi Steve,

    I am a bit unclear about how this report is set up. Are you pulling a
    boolean field off of a database and breaking on that value? By using a
    boolean field as the break value, you should be able to use the
    OnGetBreakValue or AfterGroupBreak events to change the caption of the Label
    in the Group header. You could in fact create two lables and toggle the
    visibility of each of them as a group breaks. Let me know if I'm on the
    wrong track with this.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2004
    Yes. I'm using a boolean field in the data pipeline to break the
    group. Actually, the report is more complex than I had stated. This
    is a sub-report with 2 columns (printing 2 records across), and 2
    groups. The first group breaks on a boolean which indicates the type
    of record (Type A or Type B). The second group breaks on the string
    field (item Code). When the record type (the boolean break) changes,
    I have a TppLabel and two TppLine controls that should print only
    once.

    ______________________
    Type A
    ______________________

    Code 1234
    Code 2345
    Code 3456

    ______________________
    Type B
    ______________________

    Code 4567
    Code 5678
    Code 6789

    I'v tried the OnBeforePrint and OnBeforeGenerate of the group header
    band and I've also tried the OnGetBreakValue event of the groups. I
    can trace the events and see that they are firing. However, when the
    page displays, only the results of the last firing are displayed. My
    code is similar to this:

    Begin
    if (FBreakBoolean <> myTable.BooleanField) then
    Begin
    FBreakBoolean := myTable.BooleanField;
    myLine1.Visible := True;
    myLine2.Visible := True;
    myLabel.Caption := 'Type A';
    End
    Else
    Begin
    myLine1.Visible := False;
    myLine2.Visible := False;
    myLabel.Visible := False;
    End;
    End;

    Since the last record to fire when the page is generated hits the Else
    clause, the TppLabel and TppLines don't display for the entire page.

    What am I missing?
    Steve

    On Mon, 12 Jan 2004 11:07:39 -0700, "Nico Cizik \(Digital Metaphors\)"
  • edited January 2004
    Hi Steve,

    Instead of your code below, I would do something like the following...

    Use the OnGetBreakValue to set your global boolean variable FBreakBoolean,
    then inside the GroupHeaderBand.BeforePrint event, change the
    caption/visibility of the lines based on that value.

    FBreakBoolean : Boolean;

    procedure TForm1.ppGroup1GetBreakValue(Sender: TObject; var aBreakValue:
    String);
    begin
    if aBreakValue = 'True' then
    FBreakBoolean := True
    else
    FBreakBoolean := False;
    end;

    procedure TForm1.ppGroupHeaderBand1BeforePrint(Sender: TObject);
    begin
    if FBreakBoolean then
    myLabel.Caption := 'Type A'
    else
    myLabel.Caption := 'Type B';
    end;

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.