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

Dynamic Grouping

edited October 2003 in General
I'm building my reports to use dynamic grouping and that works great.

Here's the problem:

First time the report is run with no groupby set the report runs fine.
Close the report and set a groupby and the report runs fine.
Now disable the groupby and the report is still grouping on the previous
field.

Below is the code I'm using inside the report template to enable or disable
the group. Am I doing something wrong here or is there a better way to do
dynamic grouping? The "asGroup*" functions are RAP functions I've written
to get the group by field name and label captions.

DoGroupBy := (asGroupByField <> '');

If DoGroupBy Then
Begin
GroupHeaderBand1.Visible := True;
GroupFooterBand1.Visible := True;

Group1.BreakName := asGroupByField;
DBGroupBy.DataField := asGroupByField;
GroupByName.Caption := asGroupByFriendlyField;
GroupByName.Visible := True;
End
Else
Begin
GroupHeaderBand1.Visible := False;
GroupFooterBand1.Visible := False;

Group1.BreakName := '';
DBGroupBy.DataField := '';
GroupByName.Caption := '';
GroupByName.Visible := False;
End;

Any help would be greatly appreciated.
David

Comments

  • edited October 2003
    Hi David,

    Were are you executing the code below? You may need to call Report.Reset
    before after you change the group settings. You may also want to simply set
    the group's NewPage and KeepTogether properties to False and then toggle the
    visibility. This should give you the effect you are after.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2003
    That code is being run from the Report.BeforePrint event in the report
    template.
    Can I call the Report.Reset just before the Report.Print line?

    David

  • edited October 2003
    Well I tried calling the Report.Reset just before the Report.Print line and
    that didn't seem to work.

    David

  • edited October 2003
    Hi David,

    I would suggest trying the second method I described. If you just set the
    visibility of the group to False and be sure that Group.KeepTogether and
    Group.NewPage are set to False, the group should appear to be disabled. You
    may need to call Report.Reset after you set all these properties still.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2003
    I tried that too and it didn't work either. I can't do the reset from
    inside the report template, I tried that and it gave me a compile error.
    Any other suggestions?

    David

  • edited October 2003
    Well I finally found the problem. I was not clearing the BreakName field.
    Once I did that everything started working correctly.

    Thanks
    David

This discussion has been closed.