Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Multi-dimensional arrays Post Reply Post New Topic
Author Message
mwpgr
Newbie
Newbie
Avatar

Joined: 29 Jan 2008
Online Status: Offline
Posts: 5
Quote mwpgr Replybullet Topic: Multi-dimensional arrays
     Posted: 29 Jan 2008 at 2:16pm

I am using CR X.  Is it possible to create a multi-dimensional array, capturing several fields of the same record.  Then I want output 1 field of the array to my report if the others are equal to my criteria.  This is in a subreport of details.

Right now I am searching all the detail records for a comments field that might only be populated 5% of the time and it has slowed my report considerably.  I want to build an array so I only have to search those records that actually have comments - printing them after the details themselves.  Hope this makes sense.
 
Thanks for your help.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 29 Jan 2008 at 2:58pm
This is a tough question. First off, no Crystal Reports doesn't have multi-dimensional arrays (yes, hard to believe...) So you have to figure out a way around that. One way is to use an array for each field you want to track. The second way is to use a string array and concatenate the fields together in one big string with a delimiter. Although neither idea is great, using multiple arrays might be less messy.

Now, how are you going to search those records and just print the ones you want based off the array? I have no idea. CR is designed to print array data. It just prints one element at a time, not cycle through the whole thing. I don't have any tricks around that one.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
mwpgr
Newbie
Newbie
Avatar

Joined: 29 Jan 2008
Online Status: Offline
Posts: 5
Quote mwpgr Replybullet Posted: 30 Jan 2008 at 7:31am
Hi, thanks.
I was disappointed to hear CR doesn't support multi-dimensional arrays (I am a Access/VB guy) but I used both of your suggestions.
In a subreport, I concatenated the 5 key fields into 1 array (no delimiters) and put the comment field into a 2nd array at the same counter position.
To output, I created a subreport and used a For loop.  When my record matched the Key Fields in array 1, I grabbed the comment in array 2 which was at the same position (the position was determined by my loop) and put it in a string adding carriage returns at the end of each pass - adding on the next line each time through the loop.
Not as nice as multi-dimensional, but it works.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 30 Jan 2008 at 8:56am
Ah. Adding the carriage return is a good idea. Glad it works.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum