Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Crystal report - split a field into more fields Post Reply Post New Topic
Author Message
peteGE
Newbie
Newbie


Joined: 25 Jul 2014
Online Status: Offline
Posts: 2
Quote peteGE Replybullet Topic: Crystal report - split a field into more fields
    Posted: 28 Jul 2014 at 8:23pm

Hello,

I`m new to Crystal reports and I`ve got a trouble. I have field which contains an address - street, city, zip code. The example is:
STEHLIKOVA 977 165 00 PRAHA 620 - SUCHDOL 165 00.

What I need to achieve is to split this string into three separated fields. I`ve gone trouhg a couple of forums but haven`t been able to find a proper answer. The problem is that the addresses differ so I can`t use an absolute defining of a start position. Looking at the DB (HEXA code) the parts in the string are divided by two dots:
STEHLIKOVA 977..165 00 PRAHA 620 - SUCHDOL..165 00
 

I`ve been able to work out this solution:
stringVar array x := split({cparty.STREET_ADD},"..");
Local numberVar i;
Local stringVar outputString := "";
For i:=1 to Count(x) do
 (
 outputString := outputString + x + Chr(10)
 );
 outputString;

It splits the string into three rows:
STEHLIKOVA 977
165 00 PRAHA 620 - SUCHDOL
165 00
 
And I don`t know how to find the end of each row so to be able to separate the strings and report them as three different fields.
 
Would be anyone so kind and help me out with this?
 
Thank you.

Petr

IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 28 Jul 2014 at 9:25pm
Do you always have 3 fields? If you do, you could create something like

split({cparty.STREET_ADD},'..')[1] & chr(13) & chr(10) &
split({cparty.STREET_ADD},'..')[2] & chr(13) & chr(10) &
split({cparty.STREET_ADD},'..')[3]

Edited by Gurbs - 28 Jul 2014 at 9:25pm
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.063 seconds.