Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: splitting comma saperated value in CR formula Post Reply Post New Topic
Author Message
joshimuralikris
Newbie
Newbie
Avatar

Joined: 25 Aug 2009
Location: India
Online Status: Offline
Posts: 18
Quote joshimuralikris Replybullet Topic: splitting comma saperated value in CR formula
    Posted: 29 Sep 2009 at 12:44am
Dear all,

in my crystal report i've a multiple choice Q & A, and the answer i'm saving as a string in a table i.e for my question if the user has checked 1,2 & 3 as answers i'm saving it as 1,2,3 and while retrieving i'm facing problem, i.e how to split the string in a formula and compare with specific values so that i can display check boxes in the crystal report.

in case of true or false i'm storing only true/false and after retrieving i'm comparing the fetched value with "true"/ "false" and displaying the result.

now i want to display multiple(true) checkbox options to the user in a crystal report

how can i fix this issue, please let me know...

Thanks in advance
Murali..
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 29 Sep 2009 at 7:58am
I would use Split() function and place it in a array, then you can check the array. In the array you can set multiple shared variables that you can access to set the checkboxes.
 
HTH
IP IP Logged
joshimuralikris
Newbie
Newbie
Avatar

Joined: 25 Aug 2009
Location: India
Online Status: Offline
Posts: 18
Quote joshimuralikris Replybullet Posted: 29 Sep 2009 at 11:45pm
Thnks for your reply lockwelle..

i'm saving 1,2,3,4,5,6,7 as a string in database and i'm retrieving it and spliting it and creating a array with so many number of items.

Actually MyAddr array may contain a [1,2,3,4,5,6,7] or depending on the stored string.

here is the formula i'm trying to use

if{MQM_USP_PatientQIDataElementValuesForReport;1.DataElementId}="SCIP_63" then

 whileprintingrecords;
 Stringvar array MyAddr:=split({MQM_USP_PatientQIDataElementValuesForReport;1.DataElementValue},","); 
 Local NumberVar i := 1;
 Local NumberVar arrLen := UBound(MyAddr);

For i:=1 to arrLen do
(
if(MyAddr[1])="1" then
(
chr(254)
)else
chr(168)
);


inside for loop
if(MyAddr[1]) is working fine, but when ever i try to enter 2,3,4 i'm getting an error message saying
"A SUBSCRIPT MUST BE BETWEEN 1 AND SIZE OF ARRAY"
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 30 Sep 2009 at 6:11am
probably ought to change the code to:
if  MyAddr = "1" then
 
if you only have 1 member to the array, trying to access the 2nd will error out.
 
HTH
IP IP Logged
joshimuralikris
Newbie
Newbie
Avatar

Joined: 25 Aug 2009
Location: India
Online Status: Offline
Posts: 18
Quote joshimuralikris Replybullet Posted: 05 Oct 2009 at 5:10am
Dear lockwelle,

i'm using this formula to split the string and compare with a particular value, when i check the preview of the report, its displaying * kind of symbol, and not the expected value based on the condition, i.e either check checkbox or blank check box.

please correct where am i going wrong????

if{MQM_USP_PatientQIDataElementValuesForAMIReport;1.DataElementId}="SCIP_63" then
 whileprintingrecords;
 Stringvar array MyAddr:=split({MQM_USP_PatientQIDataElementValuesForAMIReport;1.DataElementValue},","); 
 Local NumberVar i := 1;
 Local NumberVar arrLen := UBound(MyAddr);
 arrLen := 6;
For i:=1 to arrLen do
(
if MyAddr="7" then(chr(254)
)
else
chr(168) 
);
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 05 Oct 2009 at 6:32am
well, then it the question is can / does CR support printing of the ascii code up that high?  That is all symbols, and perhaps, I don't know, CR doesn't support it as it has other capabilities for display.
IP IP Logged
joshimuralikris
Newbie
Newbie
Avatar

Joined: 25 Aug 2009
Location: India
Online Status: Offline
Posts: 18
Quote joshimuralikris Replybullet Posted: 05 Oct 2009 at 6:37am
nope crystal reports are printing the chr(254) & chr(168) perfectly, but i need to know, weather the logic i'm following in my formula to split and compare each and every individual element in an array with a constant is right or wrong? 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 05 Oct 2009 at 7:22am
Ok, what if it is scip_63, but none of the myAddr are 7?  Also, shouldn't you be accessing an array member?  I don't think that MyAddr="7" cares about your variabe i.  I don't use arrays much, but shouldn't it be something like: MyAddr = "7"?
 
you might want to add the line at top chr(168);
 
that would default the formula to the value, and you can get rid of the else all together and just deal with the case of when SCIP_63 occurs.
 
HTH
IP IP Logged
joshimuralikris
Newbie
Newbie
Avatar

Joined: 25 Aug 2009
Location: India
Online Status: Offline
Posts: 18
Quote joshimuralikris Replybullet Posted: 06 Oct 2009 at 5:32am
Thanks for you response lockwelle ...

i've fixed the issue.. as i always doubted, the formula was going wrong.. i was returning a boolean previously, now i made it ri8 and returned a string every thing is working fine...

In case any one is facing such issue contact me
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.