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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting cards 4 on a page 1

Status
Not open for further replies.

lambic

Technical User
Nov 28, 2002
68
GB
Hi,

I have a requirement to produce some address cards using Crystal Reports 10 Professional, using data from a MS SQL Server 2000 database. The cards need to be printed 4 up on A4 in landscape, which I have set up with no problem, however they need to look someting like this (example using 12 records):

Page 1
Record 1 Record 4
Record 7 Record 10

Page 2
Record 2 Record 5
Record 8 Record 11

Page 3
Record 3 Record 6
Record 9 Record 12

The idea being, that when the cards cut into 4 piles, each one runs numerically when looking 'down' the pile.
I hope that makes some kind of sense, any help would be greatly appreciated.

Many Thanks
 
Try the following. First go to the section expert->details->new page after->x+2 and enter:

remainder(recordnumber,4) = 0

Also, check "format in multiple columns"->layout tab->width (maybe 3"), gap (maybe "1")->across then down.

Then in the main report, create a formula {@sort}:

if remainder({table.ID},5) = 0 then 5 else
remainder({table.ID},5)
//replace 5 with the number of pages.

This assumes, however, that you have a {table.ID} field that is sequential from 1 to n.

-LB
 
Thanks very much for that lbass, it works great.

Do you know if its possible to dynamicaly calculate the number of pages in the sort formula, so that if there are a varying number of records when the report is run, I don't have to edit the sort forumla?

Many Thanks
 
After further testing, I note that the formula above only works for a total number of records that are evenly divisible by 4.

To use the manual formula, you would change the formula to the following if there can be a total not divisible by 4. Let's say the total number of records is 35. You would use the next highest integer > 35 that is divisible by 4 (36) and divide it by 4 (=9) in the formula , as follows:

if remainder({table.ID},9) = 0 then 10 else
remainder({table.ID},9)

This will sort correctly.

To make this dynamic, if you are able to use a command as your datasource, you could do the following. Create a command like:

Select distinct table.`ID`, (select max(A.`ID`) from table A) as maxID
From `Orders`Orders

Then create the following sort formula:

numbervar x := -int(-{Command.maxID}/4);
if remainder({Command.ID},x) = 0 then x+1 else
remainder({Command.ID},x)

-LB
 
Hi lbass,

Thanks again for your help.
I've done what you suggested & created a SQL command to get the total record count (which works fine), then embedded that into the sort formula. However, it now doesn't work for some reason (data is now in same order as the table).

My sort formula is:

numberVar x := -Int (-{GetRecCount.RecCount}/4);
if Remainder ({GetRecCount.RecCount},x ) = 0 then x+1 else
Remainder ({GetRecCount.RecCount},x );

Where GetRecCount correctly returns the max record id from my table (in this case 5521).

Not sure where I've gone wrong?

Thanks again.


 
Note that you should be using the record count ONLY to define the variable. The other field in the formula should be your ID field.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top