Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP save a programmer's sanity!!!!!!

Status
Not open for further replies.

nasrogers

Programmer
May 1, 2001
9
US
Using D5 with Quick Reports 3.06. I am producing a report from 1.9million detailed records. I am using a custom preview and I use the qrprinter.preview ftn to preview the report. I produces on the screen fine. However, I can not scroll page to page...the cpu goes to 100% and never changes pages. I can save it fine. When I try to open the saved file I get the error message "metafile is not valid". I assume it is because the saved report is too large. Does anyone have any suggestions how I may get around this limitation of QR? I have posted in the Borland NewsGroup and searched qusoft's website..... I'm getting desperate!!!!!

Thanks.
 
1.9 million record will take forever to print, even on the fastest printer.

Why don't you break the data up, say into 19 reports, so around 100K records/report. Or 190 reports for 10K records/report.

Bottom line is, break the data into small chunks. It'll be easier to deal with.

You can physically break the table into smaller tables. Divide and conquer...

Or you can write a TQuickReport.OnNeedData handler, and set the MoreData to False after a certain number of records.
If you need code sample for this, just post here.
 
Thanks for getting back to me Anthony.

The customer has no plans to print the entire report. I'm sure they just want to see sections of it. We had to use a custom preview to allow the user to jump to a particular page...I think it is crazy to produce this large a report...but I'm not the customer so my opinion doesn't matter...

I would not mind seeing your code for the "OnNeedData" handler. That is something I never considered. I suspect it will be a long pause as the report re-positions to a page which it does not have the data for. This report is approx. 45,000pages. The user may want to jump from page 1 to 45,000 using our custom button.
 
Since the customer want to see sections of it.. you can speed it up by going to the first record that they wanna see.. You can use Locate etc ...

OnNeedData is called everytime QR need data (obviously)..
So when you issue QR1.Print or QR1.Preview, QR will call
the OnNeedData.
Here you must set the table to the record to print, and set the MoreData := True;
if no more data then set the MoreData := False;

Make sure you have index that suits the section you want to print.

procedure TfmPrint_ID.QuickRep1NeedData(Sender: TObject;
var MoreData: Boolean);
var OldIdx: string;
begin
if TableToPrint.Active then begin
TableToPrint.Next;
if (condition) then // When data is finished..
MoreData := False
else
MoreData := True;
end else begin
TableToPrint.Active := True;
TableToPrint.Locate ... // Go to first record..
end;
end;

Make sure when you call QR.print your table is still closed.
That's for signal to go to 1st record. Or you can always use a variable to signal it..
 
Thanks for the code. I follow your logic and I spent an hour or so playing with it. My situation is a little different though and I think that because it is different, your code won't work for me. I'd appreciate any feedback.

I am using a custom preview and a query result. As a result, I don't think the quick report object's onNeedData get's executed. Please correct me if I am wrong.

I am now trying to figure out a way to have qr produce 10000 pages and automatically save it to a file and then produce the next 10000 pages and save it and so on and so on... I can get it to save the first 10000 pages but I then want it to start a new report from the record it ended off with when it produced page 10000.

any ideas...thoughts...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top