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!

Need to pull first part of a string

Status
Not open for further replies.

Hm786

Programmer
Apr 5, 2001
88
US
Hi,

I have a company name field showing data like this

ADELPHIA MEDIA SERVICES

TIME WARNER CABLE ADCAST

COX MEDIA INTERCONNECT

I need to show the first part of the string like below:

ADELPHIA
TIME WARNER
COX MEDIA

How do I get it
Thanks,
Hamida
 
You need a rule to apply to the text.
What rule would you use to select the first 2 words in
TIME WARNER CABLE ADCAST
but only the first word in
COX MEDIA INTERCONNECT

 
I don't need any rule. I just want to display the field small because I have lots of fields to display on the report. I need enough space so I want the company name displaying only up to the second space.


Thanks,
Hamida
 
I'd put it into a table, one character longer than the length of the biggest field you will display. Check from the last character, blanking out characters until you find a character that is not blank. If you're not confident using tables in Crystal, an alternative is to use a set of MID commands plus a lot of IF ... ELSE choices, to get the same result

Of course that means that WIZZO THE DATA WIZ comes out as WIZZO THE. But it stops you turning TIME WARNER into TIME WAR etc.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
To get the first two words you would need a formula.
This is one way:

@Firsttwwords:

stringvar array x;
x:=Split({mytable.myfield}," ",3 );
if ubound(x)>1 then
x[1] & " " & x[2]
else
x[1]
 
Using lupins46's method, you could check the length of the two words using Length(@WordOne) etc. See if you can display both or just the one.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top