Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can Crystal Reports Parse a comma delimited string? 2

Status
Not open for further replies.

mGis

Programmer
Mar 22, 2001
29
0
0
US
I have been woking with SQL Server 7.0 and
I need to produce a report of questions that are answered by users:
Code:
User    A_1       A_2       A_3       A_n
101     0,0,0,0   1         1         0
22      1,2,3,4   5         3         1
3110    0,1,2,1   7         <NULL>    1

A_1 is a string delimited by comma, which I would like to parse into seperate columns. Within SQL, I can do a cross-tab report to group the users answers(above),
but now I need to find a work around to break out the string:

User    A1_1   A1_2   A1_3   A1_4     A_2     A_3     A_n
101     0      0      0      0        1       1       0
22      1      2      3      4        5       3       1
3110    0      1      2      1        7       <NULL>  1

A1_1 ... A1_n (n varies, it may be 2 other n's up to 20 or so)

SQL server 7.0 is unable to produce this in an easy manner.
My question is would Crystal Reports be able to help with this?

 
To create an array with the various answers:
//create an array variable to hold the answers for A_1
StringVar array Answer1 := &quot;&quot; ;
//populate the array variable
Answer1 := Split ({A_1},&quot;,&quot;,20) ;
//as the result of a formula cannot be an array, put an empty string as a result
&quot;&quot; ;

Formula for the 5th answer to Answer1
//check to see if there are at least 5 elements in the array - if so, show the 5th element
StringVar array Answer1 ;
If UBound(Answer1) >= 5 then Answer1[5] else &quot;&quot; ;
Malcolm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top