It would be more efficient to do this on the database as a View or Stored Procedure as opposed to within Crystal.
Also in lieu of an array, you can create 12 Running Totals and simply place the criteria within the Evaluate->Use a Formula and keep it simple.
An example would be:
month({table.field}) = 1
where 1 would be returning the sums for January.
Or you can Group by the month and place the field to sum in the details and right click it and select insert->summary->sum for each group, and Crystal will handle it all.
Since you insist upon using an array, which will be less efficent and require more code, you could create something like:
whileprintingrecords;
numbervar array MyMonths[12];
numbervar Counter;
For Counter := 1 to 12 do(
if month({table.field}) = counter then
MyMonths[counter] := MyMonths[counter]+{table.fieldtosum}
);
Also you probably want a parameter to indicate the months being returned, so create a date parameter of type range and in the Report->Edit Selection Formula->Record place:
{table.datefield} = {?MyDateParameter}
I suspect that you didn't really need an array, so in future posts try to state requirements rather than specifying architecture.
Thank you for the assistance. My goal was to learn how to create an array in Crystal since I have never done this. I attempted but could not get the proper syntax.
The example was driven by the bosses request for an array. I agree there is an easier way to obtain his goal.
And suggest to the boss that they learn to state requirements, not how things must be done as they certainly don't understand Crystal, and likely not databases as this would be easily handled in SQL.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.