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

Total Number of pages in the crosstab 1

Status
Not open for further replies.

MinniMouse

Programmer
May 11, 2004
9
CA
How can I determine the total number of pages in the crosstab inlcuindg the virtual ( horizontal pages?)
and display the actual page number by combining the PageNumber with the Horizontal page number?

I'm using CR 10 and my crosstab is in the group header with multiple groups, where each group might or might not have horizontal pages.

 
The following should work if there is only one group header per page. If there are possibly more, and they have different numbers of virtual pages, then let me know.

First, make sure that your report is sorted by your crosstab column field (within the existing group).

Then create the following formula:

//{@reset} to be placed in the group header and suppressed:
whileprintingrecords;
numbervar col := 0;
stringvar x := "";
numbervar rowlabelcol := 0;
numbervar totcols := 0;

Then create a formula {@virtpgs} and place it in your detail section (you can suppress it):

whileprintingrecords;
numbervar col;
stringvar x;
numbervar rowlabelcol;
numbervar totcols;

if instr(x,{table.field}) = 0 then
(x := x + {table.field} + ", ";
col := col + 1);
rowlabelcol := -int(-col/8); //assuming 8 column instances
//and that row labels are repeated on each page
totcols := col + rowlabelcol + 1;//total column instances
//and row labels and adding 1 total column
if remainder(totcols,9) = 0 then //if columns and label
//column (9) fit on last page
(totcols/9)-1 else
truncate(totcols/9)

Then create a second formula and place it in your page footer:

whileprintingrecords;
numbervar pageno;

if pagenumber = 1 then
pageno := pagenumber else
pageno := pageno + {@virtpgs} + 1

This will print the page number of the actual page, so that page #1 will be page 1 and if there are 4 virtual pages, then page #2 would instead appear as page #6. If there are 3 virtual pages related to the actual page #2 (now #6) then page #3 will appear as page #10, etc.

This solution does not add page numbers to the virtual pages themselves, however.

-LB
 
There could be more then one group per page and each group might not have the same number of virtual pages.
Can I add the formula use suggested and set it to be repated on horizontal pages?
 
Are you saying you need the page numbers on the virtual pages? I don't know how you could repeat the formula on a virtual page anyway--unless CR 10 has that capacity.

Maybe you should explain whether this report is only for printed use or not, since there could be a different solution, e.g., wrapping the crosstab so that virtual pages are eliminated.

So, before spending more time on this, what are you hoping for?

-LB
 
To correct my previous post:

If there is only one group per page, the reset formula should be in the group header (as indicated previously), but the last formula (let's call it {@pageno}) should be in the page header, NOT the page footer, so that it adds the virtual page count from the previous page, not the current page.

To get the correct page number when there are multiple groups per page, where each group could possibly have a different number of virtual pages:

{@pageno} should be placed in a page header_a section, and {@reset} should be moved into a page header_b section, so that the maximum number of columns contributes to the calculation of the virtual page count.

-LB
 
One more caveat: This also assumes that the detail section is hidden or suppressed or that the details are always located on the same page as the corresponding group header, since the virtual pages are calculated in the details section and the calculation must be completed before the next page header.

-LB
 
I'll try it...
BTW - the CR10 has the new property for any field - repeat on horizontal pages and has a special Horizontal page number field which is completly useless - it can not be used in any formula, can only be inserted into the report.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top