Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula string manipulation Post Reply Post New Topic
Author Message
MartinHalford
Newbie
Newbie
Avatar

Joined: 13 Aug 2009
Location: United Kingdom
Online Status: Offline
Posts: 19
Quote MartinHalford Replybullet Topic: Formula string manipulation
     Posted: 25 Jun 2015 at 2:03am
I am creating a Crystal Report which selects item A as a parameter in the main report from table X. A subreport then displays sub-items B and C from table Y (there may be 2 or 3 of these sub-items). I then want to display in a second sub-report all activity from table Z for all items and sub-items A, B, and C.

I felt one way of achieving this was having a selection formula in the second subreport of {Table Z} in ["A", "B", "C"]. This works if I hard-code the values. However, when I use a formula in the first subreport to read all the records with the following code:

stringVar subs;
WhileReadingRecords;
subs:=subs + "," + ({TableY, Column B});
subs

Firstly it returns ,B,C (note the preceding comma) but also I cannot do any string manipulation with it (e.g. Join with parameter A from the main report) because 'A string array is expected here'. So it seems I have no way of creating my required string of ["A", "B", "C"] because WhileReadingRecords always returns an array. Is there another way of putting the contents of the first subreport into a string?
Thanks!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Jun 2015 at 4:00am
is there a reason you are using sub reports instead of just joining all 3 tables in the main report? much simpler and more efficient...
IP IP Logged
MartinHalford
Newbie
Newbie
Avatar

Joined: 13 Aug 2009
Location: United Kingdom
Online Status: Offline
Posts: 19
Quote MartinHalford Replybullet Posted: 25 Jun 2015 at 4:03am
Unfortunately the data structures won't allow that. I did try that first but it will only pull the records for A, not B/C from table Z.

Thanks for your suggestion.
Thanks!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Jun 2015 at 6:04am
I would likely still try to address this at the source data but ...
maybe use an OR in sub report 2 passing the main report variable in as one half of the or and the shared variable from subreport 1 as the other half.
 


Edited by DBlank - 25 Jun 2015 at 6:04am
IP IP Logged
MartinHalford
Newbie
Newbie
Avatar

Joined: 13 Aug 2009
Location: United Kingdom
Online Status: Offline
Posts: 19
Quote MartinHalford Replybullet Posted: 25 Jun 2015 at 9:10pm
Yes but when I try to do that Crystal complains 'A string array is expected here' because WhileReadingRecords always returns an array.
Thanks!
IP IP Logged
MartinHalford
Newbie
Newbie
Avatar

Joined: 13 Aug 2009
Location: United Kingdom
Online Status: Offline
Posts: 19
Quote MartinHalford Replybullet Posted: 26 Jun 2015 at 2:25am
Also (as a little background in simple terms the table structures are such that table X has a column A (main item) that I use to select (from a parameter). Table Y has a FK back to column A and column B lists all sub-items (2 or 3 rows per main item). Table Z has many rows for each item and sub-item. If I create a simple CR all that is listed are all rows from table Z for the main item only. If you can help me identify how to display all rows from table Z for the main item and all sub-items then that would be brill!
Thanks!
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