Crystal Reports arrays

Posted on 2013-01-10
Last Modified: 2013-01-10
I need instructions to create 4 arrays in crystal report. The arrays will have 16 rows each. The arrays values come from 4 fields from the report query and the 16 rows are based on the 16 possible rows per each person (group).

How do a declare the 4 arrays with these characteristics and how do I assign the values then print each value on the report?
The report is grouped by person and shuld display something like:
                              value       Unit           AVG      estimated      
size                         c1_1        c2_1          c3_1       c4_1
height                     c1_2        c2_2          c3_2       c4_2
weight                    c1_3        c2_3           c3_3       c4_3
following 13 more rows...
Question by:sweetbuttercup
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
LVL 77

Expert Comment

ID: 38763344
Can you explain the data a bit more .  If each row is a separate record then then is no obvious need for any arrays.
Otherwise how do you identify which values go into which row.

Author Comment

ID: 38763394
If each row is a separate record = Yes.

However because of the way I need to display the valued in a grid and leave the empty space if there's no value I think I need and array. The grid has an specific order to display. So
size       = position 1              
height   = position 2
weight   = position 3                

Regardeless the order in the query result.
LVL 77

Expert Comment

ID: 38763513
I wouldn't use multiple arrays for this problem myself.

 I would provide a table of 'row headings' which included both the heading and the sort position and then use a left join from the headings table to the main table.  Every heading would be included , there is a sort field to get the correct sequence , and the layout of the columns is completely under your control.
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.


Author Comment

ID: 38763778
I'm not able to add a table to the server.. any way to do this without creating a tbl
LVL 77

Expert Comment

ID: 38763917
Can you not create say an Excel spreadsheet to contain the headings list?

In my opinion, you are in for an enormous amount of coding if you go down the array route for this .

You will have to look at each record to determine the placement of values in the arrays (potentially 16 if statements or a 16 leg case statement); you will have to build the entire report design as a grid of 16 print lines or else build an entire grid of 16 print lines in code-  you will not be able to define just one line and have it repeat.  
You have considerations of how you place the results into the report to create a properly aligned set of data in each column.

Author Comment

ID: 38763941
Need to go back to the array even if a need to create 64+ formulas to display.. The excel or extra tbl are not an option since I need to post this to a Business Obj server and cannot depend on extra files as well.
LVL 77

Accepted Solution

peter57r earned 500 total points
ID: 38764037
WHat a %^&*&!

Arrays are quite simple to use because they are very limited in functionality in Crystal.

Assuming your values are numbers then you do this to declare an array...

Numbervar array Array1;
Redim array1[16];

So you have an equivalent pair of comands for each of the 4 arrays.

Note that unlike some other languages Crystal arrays start at index 1, not 0.

So you would have a formula to fill the arrays as something like...

(repeat all the Numbervar array lines.)
If {table.dimensionfield} = "Size" then   //place in position1
(array1[1]:= {table.ValueField};
array2[1]:=.....;   //unit field
array3[1]:=....;  //avg field
array4[1]:=...... //estimated field
else if {table.dimensionfield} = "Height" then   //place in position2
(array1[2]:= {table.ValueField};
array2[2]:=.....;  //unit field
array3[2]:=....;  //
....and so on for every dimension

Then as you say, you will need 64 formula fields , each getting one value from one of the arrays to lay out the grid of resulkts.

If you are grouping the report ( so one grid per group) then you need to declare the arrays in the group header and show the results in the group footer.
LVL 100

Expert Comment

ID: 38764169
What is the data you have in the records?


Author Closing Comment

ID: 38764219
Yuk!!.. I finished!! It looks pretty ugly with all the formulas but does work!! Thank you..

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question