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

Truncate all text after ,(comma)

Status
Not open for further replies.

iwanalearn

Technical User
Sep 21, 2001
22
US
Yes, I'm a new crystal reports 9.0 user. I have 5 field that import some have data in all field and some only have data in the first field.
I read The Comlpete Reference, but couldn't relate to what I want to do.
Example of what prints
John,John1,John2,John3,John4
or
John,,,,
all I want is:
John
I'm using Formula Editor. Sorry if this has been answered somewhere else. I've been searching and haven't found a solution.
Thanks for your help
 
Try:

[tt]Split({Table.Field}, ",")[1];[/tt]

or

[tt]Left({Table.Field}, Instr({Table.Field}, ",") - 1)[/tt]

-dave
 
Hi,
Try using the Join function to turn the input into an array and then use the first array element in you rport.
Example (roughly accurate, see help for details on using arrays):
Code:
@FixData

StringVar array t := split({fieldname},",");
t[1]

Place the formula in the report insted of the field itself.

[profile]
 
Hi,
OOPS - I said Join instead of split..Try using the Join function

Besides that, Virdu had a better answer in the meantime...

Use that one..


[profile]

 
Thanks for the quick response. It works with with all the suggestions.
Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top