Groups - What am I missing?
Here is the code for my Print button click:
procedure TfmDispatchedTrucks.btnPrintClick(Sender: TObject);
begin
try
Screen.Cursor := crHourGlass;
with spReportDispatchedTrucks do begin
Parameters.ParamByName('@TheAreaID').Value := AppInfo.Area;
Parameters.ParamByName('@TheSite').Value := AppInfo.Site;
Parameters.ParamByName('@TheDispatchDate').Value :=
strtodate(dtpDate.Text);
Parameters.ParamByName('@TheShift').Value := cbShift.Text;
Parameters.ParamByName('@TheOrder').Value := rgOrderBy.ItemIndex;
Open;
/--
if rgOrderBy.ItemIndex = 0 then begin
ppGroup1.BreakType := btCustomField;
ppGroup1.BreakName := 'ppLabel2';
ppGroup1.HeaderBand.Visible := False;
ppGroup1.FooterBand.Visible := False;
end;
if rgOrderBy.ItemIndex = 1 then begin
ppGroup1.BreakType := btCustomField;
ppGroup1.BreakName := 'ppLabel2';
ppGroup1.HeaderBand.Visible := False;
ppGroup1.FooterBand.Visible := False;
end;
if rgOrderBy.ItemIndex = 2 then begin
ppGroup1.BreakType := btDataField;
ppGroup1.DataPipeline := ppDBPipeline1;
ppGroup1.BreakName := 'ppDBText11';
ppGroup1.HeaderBand.Visible := True;
ppGroup1.FooterBand.Visible := True;
end;
if rgOrderBy.ItemIndex = 3 then begin
ppGroup1.BreakType := btDataField;
ppGroup1.DataPipeline := ppDBPipeline1;
ppGroup1.BreakName := 'ppDBText11';
ppGroup1.HeaderBand.Visible := True;
ppGroup1.FooterBand.Visible := True;
end;
//--
ppReport1.Print;
Close;
end;
finally
Screen.Cursor := crDefault;
end;
end;
Basically, I let the user choose from 4 sort options. Two of the options
should break on ppGroup1 (rgOrderBy.ItemIndex 2 or 3) and two should not.
With the code above, no matter what is selected, the group never breaks. If
I take out the code between the //-- indicators the report breaks on the
group as that is the way it was designed in the designer interface. Is there
enough info here to indicate what I am doing wrong? I have nevery tried
setting groups in code so who knows....
Eric
procedure TfmDispatchedTrucks.btnPrintClick(Sender: TObject);
begin
try
Screen.Cursor := crHourGlass;
with spReportDispatchedTrucks do begin
Parameters.ParamByName('@TheAreaID').Value := AppInfo.Area;
Parameters.ParamByName('@TheSite').Value := AppInfo.Site;
Parameters.ParamByName('@TheDispatchDate').Value :=
strtodate(dtpDate.Text);
Parameters.ParamByName('@TheShift').Value := cbShift.Text;
Parameters.ParamByName('@TheOrder').Value := rgOrderBy.ItemIndex;
Open;
/--
if rgOrderBy.ItemIndex = 0 then begin
ppGroup1.BreakType := btCustomField;
ppGroup1.BreakName := 'ppLabel2';
ppGroup1.HeaderBand.Visible := False;
ppGroup1.FooterBand.Visible := False;
end;
if rgOrderBy.ItemIndex = 1 then begin
ppGroup1.BreakType := btCustomField;
ppGroup1.BreakName := 'ppLabel2';
ppGroup1.HeaderBand.Visible := False;
ppGroup1.FooterBand.Visible := False;
end;
if rgOrderBy.ItemIndex = 2 then begin
ppGroup1.BreakType := btDataField;
ppGroup1.DataPipeline := ppDBPipeline1;
ppGroup1.BreakName := 'ppDBText11';
ppGroup1.HeaderBand.Visible := True;
ppGroup1.FooterBand.Visible := True;
end;
if rgOrderBy.ItemIndex = 3 then begin
ppGroup1.BreakType := btDataField;
ppGroup1.DataPipeline := ppDBPipeline1;
ppGroup1.BreakName := 'ppDBText11';
ppGroup1.HeaderBand.Visible := True;
ppGroup1.FooterBand.Visible := True;
end;
//--
ppReport1.Print;
Close;
end;
finally
Screen.Cursor := crDefault;
end;
end;
Basically, I let the user choose from 4 sort options. Two of the options
should break on ppGroup1 (rgOrderBy.ItemIndex 2 or 3) and two should not.
With the code above, no matter what is selected, the group never breaks. If
I take out the code between the //-- indicators the report breaks on the
group as that is the way it was designed in the designer interface. Is there
enough info here to indicate what I am doing wrong? I have nevery tried
setting groups in code so who knows....
Eric
This discussion has been closed.
Comments
I've never used btCustomField - any time I've coded a break I just used
btDataField amd specified an actual data field name, have you tried
that?
EdB
1. For the first two options, where are you changing the value of ppLabel2.
Try placing a break point on that line then check the BreakName property of
the group to be sure it has not already been accessed. Also as a test, try
setting the visibility of the GroupFooterBand to true and see if that helps.
2. When using data fields as the breaking component in your group you need
to set the BreakName to the name of the field in the database rather than a
DBText component.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
goes, I am not changing the value. In that instance I do not want any break
to occur. That works just like I want. It is when I switch to the DBText
that I want breaking. I'll try your suggestion and let you know.
Thanks
Eric
Followed #2 and it worked. Thanks for the help!
Eric