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!

Clearing Array for next Group 1

Status
Not open for further replies.

kenleyc

Programmer
Jul 21, 2004
2
CA
Crystal 8.5

In my Group Footer I am creating an array that I need to clear out for the next group.

Any suggestions would be welcomed:

This is how I created the array:
Code:
WhilePrintingRecords;
Global StringVar Array arrFolderType;
NumberVar Counter;

// Count the number of subtypes for the current Applicant

(Counter := Counter + 1; 

// Redim means the size of the array is incremented to Counter's new value
// Preserve means the elements that are in the array are not removed or changed

(Redim Preserve arrFolderType[Counter]; 

// the new value is added to the new space in the array

arrFolderType[Counter] := GroupName ({V_CRYSTAL_BRU_RECONCILIATION.FOLDERTYPE})));

JOIN(arrFolderType, ',');

For some reason the last element in the Array is a duplication.

 
Change your formula as you don't need a counter (and note that global is the default for variables so you don't need to state it):

WhilePrintingRecords;
StringVar Array arrFolderType;
Redim Preserve arrFolderType[ubound(arrFolderType)+1];
arrFolderType[ubound(arrFolderType)] := {V_CRYSTAL_BRU_RECONCILIATION.FOLDERTYPE};
JOIN(arrFolderType, ',');

Its' odd that you are displaying here though, because it will do so for each group.

Generally one will display concatenated values afterwards in the report footer using:

WhilePrintingRecords;
StringVar Array arrFolderType;
JOIN(arrFolderType, ',');

-k
 
Maybe you have an outer grouping, and so you need to reset the array?

If so, in the outer grouping header use:

WhilePrintingRecords;
StringVar Array arrFolderType;
Redim arrFolderType[0];
""

-k
 
You can't redim an array with 0 elements.
Crystal chokes on that.
You could try this:

@Reset - This goes in the Group Header
Code:
WhilePrintingRecords;
StringVar Array arrFolderType;
Redim arrFolderType[1]; 
""

@Accum - This would go in the details section
Code:
WhilePrintingRecords;
StringVar Array arrFolderType;
If ubound(arrFolderType) = 1 and trim(arrFolderType[1]) = '' then
(
arrFolderType[ubound(arrFolderType)] := {V_CRYSTAL_BRU_RECONCILIATION.FOLDERTYPE};
)
else
(
Redim Preserve arrFolderType[ubound(arrFolderType)+1]; 
arrFolderType[ubound(arrFolderType)] := {V_CRYSTAL_BRU_RECONCILIATION.FOLDERTYPE}; 
);
JOIN(arrFolderType, ',');

Bob Suruncle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top