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

Numbering subsections automatically 1

Status
Not open for further replies.

hsandwick

Programmer
Sep 10, 2001
286
US
Crystal Reports 8, SQL Server 7.

Is there a way to number/alphabetize subsections automatically without building an array? We have an array built into a report, but it needs to be updated as the number of items continues to grow.

Thanks in advance,

Helen
 
I don't understand the requirement, by subsection do you mean that you've inserted sections into the report?

If so, those do have an A, B, C.. type of designation.

Perhaps you can flesh out what this means as I don't think that anyone here will inherently understand your concept.

Perhaps if you provide example data and expected output it will be clearer.

-k
 
This report probably has about 75 major subsections just for starters. Setting that aside:

This issue occurs within a subreport that is embedded within one "sub-detail" section of the main report (meaning "Detail 'ah'", or "Detail "ai", or "Detail "aj", for example), so, concentrating on this one subreport ...

Within the subreport, I simply have "Details a" and Details b" for the main subsections.

Inside "Details a", I have two formulae and one field that mirror data results if they exist.

One of the formulae builds an array, so in other words, depending on the number of results provided at run-time, each result will be preceded by the relevant array result. The result on the report would look like:

ah. Attend meeting in Louisiana. Joe Jamison
ai. Attend conference in St. Thomas. Simon Strong
aj. Meeting with team at headquarters. Frank Fellows

So, here is the formula:

shared numberVar ctr1;
local stringVar array Letter := ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];

ctr1 := ctr1 + 1;
Letter[ctr1] + ". "

Now, this is all fine until the report runs, let's say, 573 results, each of which will need an array result. Well, of course I can keep adding to the array, but from an intelligent perspective, I imagine there must be some sort of automated way to create the same kind of results that the array is creating, without having to manually update a formula.

I hope this helps to clarify the situation.

Thank you for your thoughts and suggestions,

Helen
 
Here is a formula to automatically letter up to 17,602 rows from a. to zzz. If you wanted to reset this within groups, then you could use another variable y instead of recordnumber and add a reset formula in the group header.

whileprintingrecords;
stringVar array Letter := ["a","b","c","d","e","f",
"g","h","i","j","k","l","m","n","o","p","q","r",
"s","t","u","v","w","x","y","z"];
stringvar x;
numbervar j;
numbervar k;
numbervar m;

if recordnumber <= 26 then
(j := j + 1;
x := Letter[j] + ". ") else

if recordnumber in 27 to 702 then
(if remainder(recordnumber,26) = 1 then
k := k + 1;
if j = 26 then
j := 1 else
j := j + 1;
x := Letter[k] + Letter[j]+". ") else

if recordnumber in 703 to 17602 then
(if remainder(recordnumber,676) = 27 then
m := m + 1;
if k = 26 then
k := 1 else
if remainder(recordnumber,26) = 1 then
k := k + 1;
if j = 26 then
j := 1 else
j := j + 1;
x := Letter[m] + Letter[k] + Letter[j]+". ");

-LB
 
Brilliant! Thank you, LB, this is a huge help, and I have given you a star for helping me out with this tricky situation.

Helen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top