Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Control the number of row per page dynamicaly Post Reply Post New Topic
Author Message
messi1987
Newbie
Newbie


Joined: 03 Apr 2014
Location: United States
Online Status: Offline
Posts: 7
Quote messi1987 Replybullet Topic: Control the number of row per page dynamicaly
     Posted: 06 Jun 2014 at 7:43am
Hi,
Database sql server2008
Visual basic 2010

Can we control the number of row per page
sometimes I have in the last page just the total summary what I want in the last page is at least TWO row and the total summary.
Thank in advance
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 10 Jun 2014 at 5:36am
you can, it will just probably be alot of work.

if you know how many records you have and how many fit on a page, and how your page breaks will behave, I am sure that you could make CR work as desired.

I could probably accomplish this in a stored proc, but just connecting to the database...It may be possible, it would just be even more work.

If I was doing this, I would probably use counters so I would know how close I am to completing the report so that I could force a page break.
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 10 Jun 2014 at 5:51am
do you want the same amount of record per page? Or do you only want to cut of the last page, and create on more?

If you are looking for the second, you can create a formula like:
count({table.field})

Then in Section Expert, go to Paging, and click on X-2 next to New Page Before, and use this formula:
recordnumber = {@count}-1
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 10 Jun 2014 at 5:54am
That sounds like a plan...

I don't do much with counting rows, but I think that is the sort of logic that I was coming to as I was formulating my response.

Thanks Gurbs
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 10 Jun 2014 at 5:56am
This will always cut off the last 2 records and put them on a new page. If you don't want that, you will need another formula. Let me see if I can create something that.
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 10 Jun 2014 at 6:09am
Ok, I created 3 formula's in my example.
//Count
count({table.field})
//Counter
recordnumber = {@count}-1
//Check
if {@count} / 68 <> round({@count}/68) then false else true

In my example, I was able to fit 68 records per page.
The first formula counts the number of records you have.
The second formula indicates when you would want the page break (the before the second last record)
The third record counts checks if your total number of records divided by the number of records per page is a whole number. If that is the case, you would get your results on an empty page.

In the formula for New Page Before, you place the formula

{@check} = true and {@counter} = true

This only puts the page break in place if it is the second last record, and you could just fit all your records, without totals, on 1 page.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 10 Jun 2014 at 6:14am
for the 68, couldn't you do something like:
if not onFirstRecord then
{@count} mod 68 = 0
else
false

so ignore the first record, then every time your count is a multiple of 68, force the new page...


IP IP Logged
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Posted: 11 Jun 2014 at 3:24am
Really nice solution Gurbs. Thanks for sharing.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum