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

How do you put a hard space in text so word wrap doesn't break a name 1

Status
Not open for further replies.

bwask

Technical User
May 1, 2006
4
US
I have a text box with a mix of text and fields. Some of the fields are company names and sometimes the word wrap breaks the names in the middle. Is there a way to in effect put hard spaces between the words so the word wrap treats the field as one long word?
 
Try:

replace({table.field}," ",chr(160))

So if you have text and fields, replace the field containing the company with the above formula.

-k
 
I tried it and it still treats the CHR(160) as a space.
 
Works fine here...

So I guess you need to take the time to post meaningful information.

Crystal version
Database/connectivity
Example data
Expected output

And post the formula you tried.

One line posts tend to turn most people off as it indicates that you aren't putting much effort forth. Take a look at others posts and then see the HUGE difference between yours. In most cases I only respond with please post technical information, but your question was basic enough that it might not require it, but of course I'm promoting laziness and shouldn't do so.

-k
 
I am using version 8.5
data is from Microsoft SQL Server

Sample:
Congratulations on your recent purchase of a Used 2000 Peterbilt Conventional. We would like to take this opportunity to thank you for choosing Peterbilt Of Sioux City and to provide you a list of key personnel.

Formula: Replace (LeadingCaps ({COBRN.Name})," ",Chr(160))

The field COBRN.Name that I am trying to keep together on one line contains "Peterbilt Of Sioux City".
 
What does the above formula have to do with the generated text? Are you saying that you are inserting this formula into a text box and it breaks out the name text?

I just retested this in CR XI and it works fine.

Try creating this formula, and see if it performs as expected:

"Congratulations on your recent purchase of a Used 2000 Peterbilt Conventional. We would like to take this opportunity to thank you for choosing " & replace("Peterbilt Of Sioux City"," ",chr(160))

If so, then my theory holds.

Not sure what you are doing and where, but this should work in CR 8.5 as well.

Maybe you'll need to make the whole thing a formula rather than using a text box, however I tried inserting the above formula in a text box and it worked fine.

-k
 
I put your example in the formula field and tried it in a text box and then inseted the field into the report and both ways the name would break. It must have something to do with 8.5. I cannot upgrade past 8.5 due to the lack of C++ support. I will have to work around this by reformatting the letter so the name won't be split.

Thanks for the info.
 
If you place JUST the formula pasted above in the report and shrink it, does it break correctly or not?

If not, perhaps there is some difference in CR 8.5, for instance it does not support unicode, however I would think that it would recognize hard spaces.

So the question is whether it isn't doing the replace correctly, or whether Crystal cannot recognize the chr(160).

There's always this option, which is kludgy:

Determine the length at which you'll need to break the field, then manually insert a carriage return if need be.

For instance when the field is over 20 characters, so the formula would be:

if len(trim({table.field})) > 20 then
chr(13)+{table.field}
else
{table.field}

This should work in any instance.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top