Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Getting contents of a Memo field into an Array Post Reply Post New Topic
Author Message
sirlansa
Newbie
Newbie
Avatar

Joined: 20 Dec 2006
Location: United States
Online Status: Offline
Posts: 37
Quote sirlansa Replybullet Topic: Getting contents of a Memo field into an Array
    Posted: 19 Nov 2007 at 7:28am
Each row of my database contains a memo field with a CSV vector in it of 31 numeric values. I need to display other row fields on the report page in the top and bottom sections and also display each of the vector elements [in a column] in the detail section of the report, each taken from an array element. My first problem is how to get the CSV vector into the array!
Perhaps there is a better way to approach this whole thing. Any ideas?
Sir Lansa
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 19 Nov 2007 at 9:58am
Have you looked into the MakeArray function in Help?  I haven't tested it (not having any CSV fields handy), but it should do pretty much what you want.


IP IP Logged
sirlansa
Newbie
Newbie
Avatar

Joined: 20 Dec 2006
Location: United States
Online Status: Offline
Posts: 37
Quote sirlansa Replybullet Posted: 19 Nov 2007 at 10:52am
I've made some progress--creating the array but not yet able to extract elements out of it.
 
I created a formula and hid it in the report header as follows:
shared stringVar array RefArray := split({vView.vectorOf31Elements},",",31);
This probably doesn't need to be a shared variable.
 
In any case, I now want to reference each element via a formula and place the formula in the page header or detail section as a separate control. The name of the shared variable doesn't show up anywhere on the design screen, possibly because it isn't defined until runtime. Can I just reference it by name, as in: formula = RefArray[1] and expect it to be picked up at runtime?
 
 
Sir Lansa
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 19 Nov 2007 at 11:32am
Yes, you are on the right track, and yes you do need it to be a Global variable. Now that it is in the array, you have to create a new formula for each element in the array (31 of them). Then have each formula just return that one element (as you already mentioned). The formulas will be listed in the Field Explorer window. Drag and drop them from there onto the report.

Also, you have to make sure that the array is populated prior to the formulas being printed. If you see that the formulas are returning empty values, then you need to force the array to be populated first. Use the EvaluateAfter(formula name) function to do this.

I cover everything about formulas in Chapters 5, 6, and 7 of my new CR Encyclopedia book.
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
sirlansa
Newbie
Newbie
Avatar

Joined: 20 Dec 2006
Location: United States
Online Status: Offline
Posts: 37
Quote sirlansa Replybullet Posted: 19 Nov 2007 at 1:32pm
I think we're tracking here... Thanks, all.
 
The immediate problem is that when I enter the formula for @Element1 as:
 
formula = RefArray[1], I get an error that means that RefArray is not defined. Since the array is both defined and populated in the same place (the control in the report header), I guess Crystal designer doesn't yet know it's there. How can I at least get the array defn to be recognized?
Sir Lansa
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 19 Nov 2007 at 1:36pm
First off, are you declaring it as Global in both formulas? Secondly, are you using the EvaluateAfter() function I mentioned earlier?
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
sirlansa
Newbie
Newbie
Avatar

Joined: 20 Dec 2006
Location: United States
Online Status: Offline
Posts: 37
Quote sirlansa Replybullet Posted: 20 Nov 2007 at 7:14am
Thanks, Brian. This works great! Key was defining the array both where initialized and also where used!
Sir Lansa
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.016 seconds.