Solved

Split function in Crystal Reports

Posted on 2014-01-09
5
9,827 Views
Last Modified: 2014-01-20
Hi,

I have a field that holds a string of data separated by a semi-colon ';'.  I need to split this string between 1 and 5 fields.  Once the string is split I will need to show each field that contains data in the report.  

Example of the strings:

Accelerations; Early
Accelerations; Early; Late
Accelerations; Early; Late; Recurrent
Early; Late; Variable; Recurrent

I want to display the split fields as:  
Field 1                                   Field 2                      Field 3                 Field 4
Accelerations                       Early                        
Accelerations                       Early                         Late                      
Accelerations                       Early                         Late                     Recurrent
Early                                      Late                          Variable              Recurrent
0
Comment
Question by:jul_to_cool
5 Comments
 
LVL 18

Expert Comment

by:vasto
ID: 39768711
What is your database ?
The best way to handle this is on database side.
Here is an example hot to do this with SQLServer
http://www.codeproject.com/Questions/400165/how-to-split-in-sql-server

You may also use SQLExpressions to get each part of the string
0
 

Author Comment

by:jul_to_cool
ID: 39768772
I'm using Crystal Reports 2008.
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 39769753
You can use SPLIT to separate them into an array

HOw many might there be?

Formulas to do this
Formula1 - Name - DispField1
WhilePrintingRecords;
Global StringVar Array myStrings;

myStrings:= Split({YourField},';');
If UBound(myStrings) >= 1 then
     myStrings[1]

Open in new window


One formula for each string - Just change the 2 to 3, 4, 5, etc

Formula2 - Name - DispField2
WhilePrintingRecords;
Global StringVar Array myStrings;

If UBound(myStrings) >= 2 then
     myStrings[2]

Open in new window


mlmcc
0
 
LVL 34

Expert Comment

by:James0628
ID: 39770670
If you use formulas like the ones that mlmcc posted, you would also want to add the following line to the beginning of every formula except the first one:

 EvaluateAfter ({@DispField1});

 That's to make sure that each of the other formulas is evaluated after DispField1, because it sets the myStrings variable, and the other formulas get their values from myStrings.

 James
0
 

Author Closing Comment

by:jul_to_cool
ID: 39794742
Thanks guys!!!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question