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

Error attempting to reinitialize a subreport Array

Status
Not open for further replies.

wooddsw

IS-IT--Management
Oct 7, 2003
27
US
I have a Main/Sub report task that I'm trying to modify.
The report is a sales call tracking report and the sub report gathers time off territory from the database which is used in calculating a calls per day average.
This subreport fires from the main report header one time and collects into a series of shared array variables that are accessed by the main report. This is working just fine. The array build code from the subreport looks as follows:

Code:
shared stringVar Array ArrOffTerritoryUser;
shared datevar array ArrOffTerritoryDate;
shared numbervar array ArrOffTerritoryCnt;
Redim Preserve ArrOffTerritoryUser[UBound(ArrOffTerritoryUser) + 1];
ArrOffTerritoryUser[UBound(ArrOffTerritoryUser)] := GroupName ({MCG_OFFTERRITORY.USERID});
Redim Preserve ArrOffTerritoryCnt[UBound(ArrOffTerritoryCnt) + 1];
ArrOffTerritoryCnt[UBound(ArrOffTerritoryCnt)] := Count ({MCG_OFFTERRITORY.OFFTERRITORYDATE}, {MCG_OFFTERRITORY.USERID});
Redim Preserve ArrOffTerritoryDate[UBound(ArrOffTerritoryDate) + 1];
ArrOffTerritoryDate[UBound(ArrOffTerritoryDate)] := date({MCG_OFFTERRITORY.OFFTERRITORYDATE});

Requirements have changed and I need to move the report to a group header which I know will fire it more frequently. This is necessary to be able to gather period data for date ranges greater than 1 month and include another grouping by month. Simply moving the subreport to the group header as is continued to extend the array for each successive execution resulting in the incorrect values being returned to the main report.

I’m attempting to reinitialize the array prior to execution and created a formula to be put into the subreport header that looks like the following:

Code:
shared stringVar Array ArrOffTerritoryUser;
shared datevar array ArrOffTerritoryDate;
shared numbervar array ArrOffTerritoryCnt;
Redim ArrOffTerritoryUser[0];
Redim ArrOffTerritoryCnt[0];
Redim ArrOffTerritoryDate[0];

Now when I perform a syntax check in the formula editor I receive, on any of the ReDim statements, the following error:

“The result of a formula cannot be an array”

I’m puzzled why that syntax works when I’m dynamically expanding the array but not when I want to re-initialize it. I’m open to any other suggestions or techniques to re-initialize the array to empty, erase or delete the previous variables so that they can be fresh with each execution of the subreport yet still be shared for access to the main report.
 
Reset the arrays themselves, as in:

shared stringVar Array ArrOffTerritoryUser := "";
shared datevar array ArrOffTerritoryDate := date(0,0,0);
shared numbervar array ArrOffTerritoryCnt := 0;

You can add a number, e.g., 1, at the end of the formula, if you get an error message because of the array.

-LB
 
Found out I can add this line to the end of the formula

' '

The formula will then return a blank character rather than the array.

Crystal formulas return the last value they evaluate. In this case it is the array declaration and thus an array is being returned.

I did have to change the dimension subscript from 0 to 1 to eliminate the "subscript must be between 1 and 1000" error message. Not sure yet whether this will impact the loop test in the main report but I don't think it will.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top