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

Contents page or Index Page

Status
Not open for further replies.

IanWaterman

Programmer
Jun 26, 2002
3,511
GB
Please help, I posted this as "Build an Index" the other day and got no replies. Can someone at least comment on what I am doing wrong, or tell me that what I am trying to do is impossible.

I am not using groups so I can not use the CrystalDecisions solution, however, i have adapted and it almost works.

The report was designed by someoneelse and they have just presented info in details sections (about 30). Most sections run subreports, but a couple of sections collect data from the main report.

I am building a dynamic array using 3 formulas (below)inserted in each detail section(all are different but have a similar structure to those below) which move the array count on by 1 each time, check page number and manually insert title of text box from each section.


whileprintingrecords;
//a counter that will be used to determine array position
if {@fCheckLatest} = 'No' then global numbervar counter1:=counter1 else
counter1:=counter1 + 1;

//whileprintingrecords;
evaluateafter({@ArrayPosition-Gen}); //to ensure stability of the formula this should run after the counter formula
//referencing the variables declared in the report header a
shared numbervar array PageNumberArray;
global numbervar counter1;
if {@fCheckLatest} <> 'No' then PageNumberArray[counter1]:=pagenumber;
//this is where the current pagenumber is stored at the array position of the counter

whileprintingrecords;
evaluateafter({@ArrayPosition-Gen}); //to ensure stability of the formula this should run after the counter formula
//referencing the variables declared in the report header a
shared stringvar array CoverNameArray;
global numbervar counter1;
if {@fCheckLatest} <> 'No' then CoverNameArray[counter1]:=&quot;General Information&quot;
//this is where the current pagenumber is stored at the array position of the counter


The formulas appear to work perfectly, in tests I show values on relevant sections and all is OK. However, when I show contents of the Array at the end of the report, the pagenumber for the sections containing subreports are OK, however, for the sections of the main report the page numbers have been overwritten.

It seems that the first parse which is what is displayed on screen, the page produces correct data, but I am guessing when the subreports are run in the second parse, the main report data pagenumbers are generated again and then updated with the page number of the location of the first subreport.

Any ideas on how I can stop this from happening.

Ian
 
I don't think you can.

I have done something along the lines of what you did but I didn't have any subreports to cause problems with the pagecount. Subreports which split across pages or occupy more than one page themselves are a problem since Crystal seems to forget where it is when in a subreport and paging information isn't passed back to main report from the subreport.

you don't give us the complete formulas involved so I cannot comment on them....ie there are formulas-within-formulas that you don't lay out....eg. {@fCheckLatest}

You use &quot;whilePrintingRecords&quot; in your basic formulas (which isn't really necessary however when EvaluateAfter is used)....frankly I don't see the necessity for 3 formulas...the 3 formulas could be combined into one formula

//@Indexing

WhilePrintingRecords;
numbervar counter1;
shared numbervar array PageNumberArray;
shared stringvar array CoverNameArray;

if {@fCheckLatest} <> 'No' then
(
counter1:=counter1 + 1;
PageNumberArray[counter1]:= pagenumber;
CoverNameArray[counter1]:= &quot;General Information&quot;;
);


There...now all three formulas are combined into one If-then statement...But many support formulas are missing..eg. There should be an initializing formula somewhere probably in the report header suppressed and there should be display formulas for the results.

I assume this is only an example section since otherwise everything would be given the covername &quot;General Information&quot;.

Just make sure {@fCheckLatest} has WilePrintingRecords as part of it's formula....probably that formula is not necessary as well and could be incorporated into the formula above that I've written.



Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
I tried looking at your earlier post and testing it out, but, like Jim, I couldn't go further without the rest of the formulas--the display formulas in particular.

-LB
 
LB & Jim

Thank you for your comments, Jim you are quite right, one formula will do. I ended up with 3 as I was developing from the Crystal Decision model. Also I wanted to display the result of each formula so that I could test data was correct. When the formulas print in their respective locations the data page number, title and array postion are all correct. However, when I display array results the page numbers are wrong.

I have a reset formula in report header
whileprintingrecords;
//the arrays are declared with blank values of the appropriate type
//the arrays have been set for an initial size of 300 positions
//Limitations of arrays in version 8 of Crystal Reports are 999 positions
//If the array is not large enough Crystal will generate an error message when running the report

shared numbervar array PageNumberArray:= [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];

shared stringvar array CoverNameArray:= [&quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;,
&quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;];

numbervar counter1:=0; //the counter for the main report that will be used to set the array position

There will be a separate formula for each section so that the page title will vary.

At the moment for testing I am using simple display formulas, JOIN for the string array and a simple list for the number array.

join(shared stringvar array covernamearray,&quot;,&quot;)
data displayed is correct

shared numbervar array PageNumberArray;

totext(PageNumberArray[1])+&quot; ,&quot;+totext(PageNumberArray[2])+&quot; ,&quot;+totext(PageNumberArray[3])+&quot; ,&quot; etc.

Checklatest is a simple formula to conditionally suppress duplicated records, as the data gets updated each record has a version number, checklatest simply ensures it is the latest version.

I have added Whilepritingrecords to Checklatest and this has made no difference, report is OK, client is happy with the report he just now wants an index or table of contents.

Ian
 
As far as getting the correct page numbers go...I think that is a sub-report problem(they get in the way of accurate page counts sometimes)

I would give some thoughts to making PageNumberArray a string array. The advantage is that it is initialized to NUlls and hence you don't have to be careful about the display of values that are not updated.



Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top