merge two reports together
I know the programmers' manual shows how to do this if you have saved reports ie
I have a form that generates sql and prepares an invoice report in one part of the application (optionally priniting it) and a different form that generates sql and prepares and prints a reminder letter.
I'd like to include a copy of the invoice report with the letter report.
In my my Invoice form I have a procedure TFrmInvoice.PrepareInvoice(invoiceID:integer) that correctly does all the work to make an invoice and ends with the line
How can I translate the code in the programmers manual to the situation when I am not calling LoadFromFile() ?
Howard
I do not have saved reports.frxReport1.LoadFromFile('1.fr3');
frxReport1.PrepareReport;
frxReport1.LoadFromFile('2.fr3');
frxReport1.PrepareReport(False);
frxReport1.Print;
I have a form that generates sql and prepares an invoice report in one part of the application (optionally priniting it) and a different form that generates sql and prepares and prints a reminder letter.
I'd like to include a copy of the invoice report with the letter report.
In my my Invoice form I have a procedure TFrmInvoice.PrepareInvoice(invoiceID:integer) that correctly does all the work to make an invoice and ends with the line
The code in the reminder form does all the work to make the letter and ends withFrmInvoice.frxRptInvoice.prepareReport(false);
but I only get the letter shown, not the invoice.FrmPrintInvoiceReminder.frxReportInvoiceReminderLetter.PrepareReport(true);
FrmInvoice.PrepareInvoice(TheInvoiceID); //<--- call the proc to prepare and append the invoice
FrmPrintInvoiceReminder.frxReportInvoiceReminderLetter.ShowPreparedReport; //<-- here I want to show them both
How can I translate the code in the programmers manual to the situation when I am not calling LoadFromFile() ?
Howard
Comments
Using memorystreams.
save invoice to memorystream
save letter to memorystream
using a 3rd frxReport.component use
frxReport1.LoadFromStream( invoiceStream );
frxReport1.PrepareReport;
frxReport1.LoadFromStream( letterStream );
frxReport1.PrepareReport(False);
frxReport1.Print;
I did try that but I didn't use a third report. In algorithmic form I did the following
Unfortunately though, although I had streamed both reports to the same stream, and loaded the whole stream back in, only the first report (letter) report was printed
I'll have another go using a third, empty report as you sugest.
Thank you technisoft, I eventually got it working that way. I am using quite a few script variables in the letter report and found that I had to repeat setting up the script variables again in the combined report. So the solution was not quite as slick as I thought it would be compared with simply printing one report after another.
However in case anyone else is following this below is the code I finally used.
(The procedure names should be self explanatory )