Hello, i have problem ti print frCompositeReport.
I have a function that works perfectly pinting frReports (function below) but i have now a frCompositeReport that i need to print,
How can i change this function to able to print frCompositeReports
I changed var TheReport: TfrReport to var TheReport: TfrCompositeReport;
but when execute, send: Access Violation
procedure PrintReport( var TheReport: TfrReport; iCopies: ShortInt);
var
iFromPage,
iToPage,
NumberCopies: Integer;
ind: Integer;
Collap: Boolean;
begin
if not TheReport.PrepareReport then Exit;
// Set up dialog with some sensible defaults which user can change
with TPrintDialog.Create( nil ) do begin
Options:=[poPageNums ]; // allows selecting pages/page numbers
Copies:= iCopies;
Collate:=true; // ordened copies
iFromPage:=1; // start page
iToPage:= TheReport.EMFPages.Count; // last page
MaxPage:= TheReport.EMFPages.Count; // maximum allowed number of pages
if Execute then begin// show dialog; if succesful, process user feedback
if (Printer.PrinterIndex <> ind ) // verify if selected printer has changed
or TheReport.CanRebuild // ... only makes sense if we can reformat the report
or TheReport.ChangePrinter(ind, Printer.PrinterIndex) then //... then change printer
TheReport.PrepareReport //... and reformat for new printer
else
exit; // we couldn't honour the printer change
if PrintRange = prPageNums then begin// user made page range selection
iFromPage:=FromPage; // first page
iToPage:=ToPage; // last page
end;
NumberCopies:=Copies; // number of copies
// Print the report using the supplied pages & copies
TheReport.PrintPreparedReport( IntToStr( iFromPage ) + '-' + IntToStr( ToPage ), NumberCopies );
end;
Free;
end;
end;
Tested on windows 11, KdeNeon
Lazarus 2.2.2