Home General

Access Violation When sending reports straigt to printer

edited August 2001 in General
I use the code below to send reports straight to a printer. Its stripped
down code - my actual code has a lot of code to manually set text on
differnt labels in the report. If I wait for the full report to print before
choosing to print again everything works fine. But I select to print again
too quickly then i get an access violation - but the violation will occur at
different places in the code. By using the hour glass i stop the users from
selecting to print again until the block of code is done but the reports
still seem to overlap and confuse each other. Any help is greatly
appreciated

procedure TflightWorksheetForm.CarrierItinerary1Click(Sender : TObject);
var
lPrintDevice : tppprinterdevice;
begin
screen.cursor := crHourglass;

//create the report object
flightReport := TflightReport.Create(Self);
reportBuilderDataModule.reportTemplateTable.close;
reportBuilderDataModule.reportTemplateTable.open;
flightReport.Template.New;
flightReport.Template.DatabaseSettings.DataPipeline :=
reportTemplatesPipeline; //a pipeline on my form
flightReport.template.DatabaseSettings.NameField := 'report_name';
flightReport.template.DatabaseSettings.TemplateField :=
'report_template';
flightReport.template.DatabaseSettings.Name := 'carrierItinerary';
flightReport.template.LoadFromDatabase;

/////set the printer and print///////////////////

lPrintDevice := tppprinterdevice.Create(Self);
lPrintDevice.Publisher := flightReport.Publisher;
flightReport.PrintToDevices;
lPrintDevice.Free;

//////////////////////////////////
flightReport.Free;
screen.cursor := crArrow;
end;

end;

Comments

This discussion has been closed.