So I spent the last couple days searching the net for how to build a table of contents into a Crystal Report that would let me know what pages my group headers appeared on. There were only a couple subtle references out on the net but mostly people posing the question with either no answer or an answer directing them to a kb article by Crystal that has since been removed with Crystal being now owned by SAP.
I was finally able to figure out how to build an index page. Basically a table of contents that appears at the end of the report instead of the beginning.
I made two formulas:
The first one is called IndexBuilder. In it I placed the category header. Each time the header changed the function would get called and populate the array variables with the category and current page number:
The second formula IndexPrinter takes the array that was build while the report was being generated and prints the line items. It is placed in a report footer with a new page call in the section expert making it a seperate page.Code://this function builds the indexes based on categories in the report WhilePrintingRecords; StringVar Array catArry; NumberVar Array pageArry; IF NOT (GroupName({Table.Field}) IN catArry) THEN ( Redim Preserve pageArry[UBound(pageArry) + 1]; pageArry[UBound(pageArry)] := PageNumber; Redim Preserve catArry[UBound(catArry) + 1]; catArry[UBound(catArry)] := GroupName({CategorySummary.CatalogTitle}); ); ""; //the formula has to print something even if it's an empty string to run at all
I would still prefer to see this exact same thing appear at the beginning of the report as a Table of Contents so if anyone has any brilliant tricks please chime in.Code://this function prints the arrays built throughout the creation of the report, functionally a TOC/Index of the report catagories WhilePrintingRecords; NumberVar i; NumberVar j; StringVar Array catArry; NumberVar Array pageArry; StringVar Array Output; Redim Output[UBound(catArry)]; FOR i := 1 to UBound(catArry) do ( Output[i] := "Page " + Left(CStr(ToText(pageArry[i],0))+": ",5) + catArry[i]; ); Join(Output,Chr(13))
Scuz




Reply With Quote