Print Page | Close Window

Print records on next page based on condition

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=16472
Printed Date: 19 May 2024 at 2:39am


Topic: Print records on next page based on condition
Posted By: forum_usr
Subject: Print records on next page based on condition
Date Posted: 17 May 2012 at 4:39am
Hi All,

I have a requirement where I need to print all records in Detail Section on a new page if field values meet condition and if such records are more than 3.

The condition is that the values in the table field should not be equal to 'Y' and such records need to be more than 3.

This condition needs to be calculated for the records in the Detail Section so I need formula to count number of records based on condition and dynamically enable the 'New Page After' option so that it pushes the section on a new page.

I have a grouping on the report so i m assuming i would need to use the "New Page After" option on the Group Header immediately above the Detail section since I m planning on displaying the records mentioned above in the Detail section.

It would be great if this can be done using a formula because I have some more requirements that are based on the condition mentioned above i.e. if there are more than 3 records that are matching a criteria then I need to display a message etc.

Please help me with your suggestions.

Thank you.



Replies:
Posted By: kevlray
Date Posted: 17 May 2012 at 5:10am
I sure you would have to create a formula.  And I am pretty sure you would need a shared variable that would 'count' the records that match the criteria.  You would then use that shared variable in the "New Page After" option.  Of course you would have to reset the shared variable after doing the "New Page After".  Without knowing a lot more details, it would be difficult to come up with an exact solution.

I hope this helps. 


Posted By: forum_usr
Date Posted: 17 May 2012 at 6:26am
Hi Kevlray,
Thanks for your prompt reply. I have tried using the shared variable option in a formula & placed it in the DETAIL SECTION to count records based on condition like this:

shared numbervar x;
if ({table.fieldname}) <> 'Y' then
x:=x+1;

but when i place the below formula in GROUP HEADER "New Page After", it doesnt work (i think it is because Group Header is ABOVE the Detail Section and the shared variable has not calculated records in the Detail section, but then how do i count Detail Section records dynamically i.e. before they print):

shared numbervar x;
if x > 3 then
true

Please help...


Posted By: kevlray
Date Posted: 17 May 2012 at 12:25pm
I believe you would have to put the formula in the details, then in the Group Footer, in the "New Page After" do the check for the shared variable. 

I have not experimented with this yet, so I am guessing a bit.


Posted By: kevlray
Date Posted: 17 May 2012 at 12:26pm
Then again maybe you need to put the check in the details section.


Posted By: fjgjh687uo8
Date Posted: 17 May 2012 at 9:06pm
bumb ubm!


Posted By: forum_usr
Date Posted: 18 May 2012 at 3:20am
Thanks for your suggestions Kevlray. I'll try these options and hopefully get it to work.



Print Page | Close Window