Accessing Page numbers in report document (VS2005, CR XI)
Hi everyone, I'm wondering if anyone has any code that can return a page count based on a value in the report. I am creating an invoice and some of the invoices go over one page, this is bad because it changes the weight of the letter and it can't be presorted. I'm just trying to pull the multi-pagers out.
Right now my only solution is counting the number of lines that would be printed for each account. This method isn't fool proof though because there is a subreport which varies in size as well.
I have the Crystal Reports for .NET programming but it doesn't state whether it can be done or not. I haven't had any luck finding answers in my search and there are barely any topics on the matter which leads me to believe that it can't be done. Anybody know? Thanks a lot in advance.
Re: Accessing Page numbers in report document (VS2005, CR XI)
Quote:
Originally Posted by slaws
Hi everyone, I'm wondering if anyone has any code that can return a page count based on a value in the report. I am creating an invoice and some of the invoices go over one page, this is bad because it changes the weight of the letter and it can't be presorted. I'm just trying to pull the multi-pagers out.
Right now my only solution is counting the number of lines that would be printed for each account. This method isn't fool proof though because there is a subreport which varies in size as well.
I have the Crystal Reports for .NET programming but it doesn't state whether it can be done or not. I haven't had any luck finding answers in my search and there are barely any topics on the matter which leads me to believe that it can't be done. Anybody know? Thanks a lot in advance.
Without knowing anything about your report, the layout and whatever, I have to say no. The report can't possibly know the number of pages needed until after it has been created. You are going to have to come up with a way to either count lines or something and prevent the report from being printed.
Of course I may be wrong so check out www.businessobjects.com and search their support forum.
If there is a way I'd love to see it becasue I had to research a similar problem. I wound up counting detail lines.. :)
Re: Accessing Page numbers in report document (VS2005, CR XI)
Thanks for the reply King George. I am building the report in full and I can return the total number of pages. I'll keep hacking away at it. Thanks again.
Re: Accessing Page numbers in report document (VS2005, CR XI)
Hi slaws,
Can you forward me that code ? I need it!!!
Thanks
Re: Accessing Page numbers in report document (VS2005, CR XI)
Well, I don't have much. This code gets the total page count. This assumes that CReport is a loaded Report Document.
VB Code:
Dim strPageCount As String
strPageCount = CReport.FormatEngine.GetLastPageNumber(New CrystalDecisions.Shared.ReportPageRequestContext)
I still don't have a way to get individual page counts. What I've done is take the total number of pages (the code above) minus the total number of records. The difference will be the total number of extra pages. Then I go through the database and calculate the number of lines that will appear on the report and start knocking off the ones with the highest line count.
I suppose I could load a report document for each record individually and return the total page count for each one but I'm dealing with upwards of 40k records and that would take forever.
I'm sorry I couldn't be more help.