Dynamic Grouping
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
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
This discussion has been closed.
Comments
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.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
template.
Can I call the Report.Reset just before the Report.Print line?
David
that didn't seem to work.
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.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
inside the report template, I tried that and it gave me a compile error.
Any other suggestions?
David
Once I did that everything started working correctly.
Thanks
David