Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Can you say shared variable ?? Post Reply Post New Topic
Author Message
bobj
Newbie
Newbie


Joined: 15 Aug 2008
Location: United States
Online Status: Offline
Posts: 2
Quote bobj Replybullet Topic: Can you say shared variable ??
     Posted: 15 Aug 2008 at 9:20am
My goal is to pull inventory information from a btrieve database into
    crystal and generate a report that combines the 16 lines of text from
    a single (40 char string) field in the database into a single field. The problem I'm having is I can't figure out the formula to combine the single 40 char descr field and the 2 char lineno field to allow the other 15 lines to show on the report.
    structure of the database is as follows:
    lineno, string (2)
    descr, string (40)
If I can get all 16 lines to show I what to combine them into a single field for export to a web catalog. 
I've tried pulling directly into the main report and using shared variable and passing the info back, but I either get only the first field in the main or only the last field in the sub.

I don't care if I concatenate or append  the 16± lines in the sub or the main. The end result is I want a single field of text to export from crystal containing whatever text is available. 

I'm reasonably sure I've not using the correct syntax. I'm not sure of how to append the fields into one string, nor whether my shared variables are passing the info correctly??
Formula in sub report is: @My_Extdesc
whileprintingrecords;
Shared stringVar combined;
combined:= {INDESC.descr}
Formula in main report is:
whileprintingrecords;
Shared StringVar combined:= combined
If there's an easier way please let me know, and no, you can't hurt my feelings, I already know I'm over my head.  Thanks.
bobj
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 15 Aug 2008 at 11:29am
In the subreport, try using this line instead of your existing one:
whileprintingrecords;
Shared stringVar combined;
combined:=  combined + " " + {INDESC.descr};

and then in the main report, don't assign combined to combined. Since it is a shared variable, it already has the data you want.
whileprintingrecords;
Shared StringVar combined;

Try that out and let us know how it goes.
I have the complete Crystal syntax documented with sample code in my Encyclopedia book. You can find out more about my books at Amazon.com or reading the Crystal Reports eBooks online.
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
bobj
Newbie
Newbie


Joined: 15 Aug 2008
Location: United States
Online Status: Offline
Posts: 2
Quote bobj Replybullet Posted: 15 Aug 2008 at 11:49am
Brian,
Thanks for your help. I'm guessing it's getting closer because now I get an error message saying "A string can be at most 254 char... long"?
 
p.s. I looked for your book at Barnes&Noble but they only had the net book. I'm using 8.5 and wasn't use how backward compatiable the Encyclopedia XI was?
bobj
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 15 Aug 2008 at 12:47pm
Yes, with that error, you definitely have it working. Another idea is to create a couple strings and use if-then statements to check string size and use the next string when the first one gets close to max size.
 
Re the book, the XI book will obviously have new features that you don't have access to with 8.5. But formulas and reporting techniques are the same across all versions. Anyway, you could always order it at B&N to see if it might be good for you or not and if you don't like it then just don't buy it. Nonetheless, I think your current report problem should be close to being solved now. 


Edited by BrianBischof - 15 Aug 2008 at 12:47pm
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
jdbrau03
Newbie
Newbie


Joined: 04 Jun 2012
Online Status: Offline
Posts: 13
Quote jdbrau03 Replybullet Posted: 12 Jun 2012 at 4:49am
I had a similar problem to what was stated above.  I used the formula and the text combined wonderfully.  I am having an issue now, where some records are being returned multiple times while others are only returned once.  Do you have any recommendations on how to fix this?
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