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

Would like to truncate long Report Titles 2

Status
Not open for further replies.

jomax

Programmer
Jun 16, 2003
18
US
I am reporting on Article usage. Some of the article titles are very long, and I would like to limit the length to 100 characters, and add ' ...' to the end.

It's easy enough to do a left(fieldname, 95), but how do I format it so that I don't cut off the title in the middle of a word, in other words, find the next space after 85 characters?

Thanks in advance
 
hi
Related topics
Trim (str)

TrimRight (str)

Formula 14

pgtek
 
Jomax,

Sounds like you want to make sure you trim tidily. i.e. "Trim me here" rather than "Trim me her".
Code:
WhilePrintingRecords;
StringVar SValue1;
StringVar XValue1;

SValue1 := {YourField};

If Length(SValue1) > 30
Then
XValue1 := Mid(SValue1,1,30)
Else
XValue1 := SValue1;

If XValue1 <> SValue1
Then
StrReverse(Mid(StrReverse(XValue1),InStr(StrReverse(XValue1),' ')))
Else XValue1;

Naith
 
Naith,

That's it!!! thanks so much for your help! Terrific.....
 
Or you might use:

left({Table.Field},
switch
(len({Table.Field}) <= 100, len({Table.Field}),true, instrrev({Table.Field}, &quot; &quot;,100)))
+
(switch(len({Table.Field}) <= 100, &quot;&quot;,true, &quot;...&quot;))

-k
 
Another excellent solution, thanks synapsevampire!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top