Crystal Reports.NET problems accessing FieldObject for page count

Posted by Stuart A on Stack Overflow See other posts from Stack Overflow or by Stuart A
Published on 2009-11-11T16:09:06Z Indexed on 2010/06/10 13:22 UTC
Read the original article Hit count: 230

Filed under:

Hi,

We're using Crystal Reports.NET that was bundled with VS2005. We have a confirmation booking form letter report that we want to batch print. Generally this prints one page per person on letterhead paper, however occasionally if they've booked lots of courses the letter rolls over to two pages. The second page should not be printed to letterhead paper.

Basically, because it's a rare occurance I was just going to print the lot and pause if a particular letter went over 1 page. I.e. Load the report, grab the page count, hollah at the user if it's more than one page otherwise carry on regardless.

I have dropped a TotalPageCount on the footer of my report (Which I would supress if it worked!) and then try and read it in my application.

Once I've loaded the document I am trying to call

report.ReportDefinition.ReportObjects("TotalPageCount1")

Which is of type CrystalDecisions.CrystalReports.Engine.FieldObject

I cannot seem to get the value out of this for love nor money (nor any amount of cursing and swearing!)

I can read any items of type TextObject, but if I append the TotalPageCount to a text field, it shows correctly in the report but then returns "Page count: TotalPageCount" rather than "Page count: 1" for example.

Soo, short of going out of my mind, does anyone have any suggestions? Either a way to read the value or a way round it. The printer doesn't have multiple trays, though even if we got one, I'm not sure how to convince crystal to print different pages to different trays.

Best regards,

Stuart

P.S. - is it a sign that the "crystal-reports" tag has a count of 666? :O(

© Stack Overflow or respective owner

Related posts about crystal-reports