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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Split String

Status
Not open for further replies.
Dec 16, 2008
83
GB
Crystal XI

Hi, i have a string like below:

Single trip, Age 18-35, England

What i'd like to do is split this string first two commas into its own seperate fields and then group upon them. the first one i've done with the following formula:

If Not({tblInsuredPerson.PremiumID} like "X*") then Left({tblInsuredPerson.InsuredName},(Instr({tblInsuredPerson.InsuredName},",")))

however i'm struggling with getting the age out, preferably with no commas and no spaces either side, can anyone help?
 
Treat the elements as separate fields, Split({field}, ",")[2] and so on.

Depending on your data, you may need extra logic, maybe REPLACE for "Age" and UBOUND to test how many elements you have.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
i've tried:

If Not({tblInsuredPerson.PremiumID} like "X*") then Split({tblInsuredPerson.InsuredName}, ",")[2]


however i get the following error,

"A subscript must be between 1 and the size of the array"

any ideas?
 
Use 'Ubound' to check if the string will split as you expect.

Have you tried displaying the data? It may not be what you think it is.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top