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

Crystal Report Array

Status
Not open for further replies.

JDMiller

MIS
Feb 17, 2004
60
US
I am using Crystal Reports 8. I want to create a year array containing 12 buckets.

How and where do I create this array so that I can read thru my records and load each month as a running total count as I read thru the records.
 
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}
);

Now you can reference each month using:

whileprintingrecords;
numbervar array MyMonths[12];
MyMonths[1]

where [1] would be January.

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.

-k
 
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.
 
Oh, if that's all you were asking, hit F1 and put array into the index, there are examples there.

-k
 
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.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top