Problem with printing report, repeats the same record endlesly
Hello,
I have a problem when trying to print a report from delphi, I have a table
with 15 records and when I design the report and preview it it is working
well. but when I try to print it using delphi code I get the same record
over and over again. I do not give any parameters to restrict the recordset.
Any one have a suggestion what I do wrong?
code I use to print:
var
ReportLabel : TppLabel;
begin
if qryItem.Locate('ItemName', ReportName, []) then begin
ppModalReport.Reset;
ppModalReport.Template.DatabaseSettings.Name := ReportName;
ppModalReport.Template.LoadFromDatabase;
ppModalReport.ShowPrintDialog := False;
if Preview then
ppModalReport.DeviceType := 'Screen'
else
ppModalReport.DeviceType := 'Printer';
if PrinterName = '' then begin
PrinterName := 'Default';
ppModalReport.ShowPrintDialog := True;
end;
if BinName = '' then begin
BinName := 'Default';
end;
ppModalReport.PrinterSetup.PrinterName := Trim(PrinterName);
ppModalReport.PrinterSetup.BinName := Trim(BinName);
ppModalReport.PrinterSetup.Copies := Aantal;
if ParameterValue <> '' then begin
ppModalReport.AutoSearchFields[0].SearchExpression := ParameterValue;
end;
if WatermarkLabel <> '' then begin
ppModalReport.CreateDefaultBands;
ReportLabel := TppLabel.Create(Self);
ReportLabel.Band := ppModalReport.HeaderBand;
ReportLabel.spLeft := 100;
ReportLabel.spTop := 200;
ReportLabel.Caption := WatermarkLabel;
ReportLabel.Angle := -60;
ReportLabel.SendToBack;
ReportLabel.Font.Size := 80;
ReportLabel.Font.Style := ReportLabel.Font.Style + [fsBold];
ReportLabel.Font.Color := $00DADADA;
end;
ppModalReport.Print;
The Parameter value is empty.
Thanks
Rob
I have a problem when trying to print a report from delphi, I have a table
with 15 records and when I design the report and preview it it is working
well. but when I try to print it using delphi code I get the same record
over and over again. I do not give any parameters to restrict the recordset.
Any one have a suggestion what I do wrong?
code I use to print:
var
ReportLabel : TppLabel;
begin
if qryItem.Locate('ItemName', ReportName, []) then begin
ppModalReport.Reset;
ppModalReport.Template.DatabaseSettings.Name := ReportName;
ppModalReport.Template.LoadFromDatabase;
ppModalReport.ShowPrintDialog := False;
if Preview then
ppModalReport.DeviceType := 'Screen'
else
ppModalReport.DeviceType := 'Printer';
if PrinterName = '' then begin
PrinterName := 'Default';
ppModalReport.ShowPrintDialog := True;
end;
if BinName = '' then begin
BinName := 'Default';
end;
ppModalReport.PrinterSetup.PrinterName := Trim(PrinterName);
ppModalReport.PrinterSetup.BinName := Trim(BinName);
ppModalReport.PrinterSetup.Copies := Aantal;
if ParameterValue <> '' then begin
ppModalReport.AutoSearchFields[0].SearchExpression := ParameterValue;
end;
if WatermarkLabel <> '' then begin
ppModalReport.CreateDefaultBands;
ReportLabel := TppLabel.Create(Self);
ReportLabel.Band := ppModalReport.HeaderBand;
ReportLabel.spLeft := 100;
ReportLabel.spTop := 200;
ReportLabel.Caption := WatermarkLabel;
ReportLabel.Angle := -60;
ReportLabel.SendToBack;
ReportLabel.Font.Size := 80;
ReportLabel.Font.Style := ReportLabel.Font.Style + [fsBold];
ReportLabel.Font.Color := $00DADADA;
end;
ppModalReport.Print;
The Parameter value is empty.
Thanks
Rob
This discussion has been closed.
Comments
My first guess would be that the label you are creating is too big to fit
into the header band and therefore causing the report engine problems. As a
test, try commenting out the Watermark code below and see if that is the
problem. If so, be sure the header band is sized to fit the label
especially since you have it at an angle.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com