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

How to Remove final comma at end of text object field

Status
Not open for further replies.

pectin232

Technical User
Jan 22, 2011
67
US
In the code below... there is always a comma at the end of it... I am not sure how to suppress the last comma... it would say: emails, no contact, supervised, letter, phone call, unsupervised visits,
There are values in it like this:
emails, no contact, supervised, letter, phone call,

The problem is I only like to remove the last comma which is after the phone call.... there can be more after phone call, like unsupervised visits as well or even be just 2 like emails[comma] and supervised[comma].


TRIMLEFT({@Visit Type - Email}+' '+{@Visit Type - No Contact}+' '+{@Visit Type - Supervised}+' '+{@Visit Type - Letter}+' '+{@Visit Type - Phone Call}+' '+{@Visit Type - Unsupervised Visits})
 
If there is ALWAYS a comma, you could set up your formula like this:

stringvar x := TRIMLEFT({@Visit Type - Email}+' '+{@Visit Type - No Contact}+' '+{@Visit Type - Supervised}+' '+{@Visit Type - Letter}+' '+{@Visit Type - Phone Call}+' '+{@Visit Type - Unsupervised Visits});
if len(x)>1 then
left(x,len(x)-1)

If there is only sometimes a comma on that end, you need to show the content of each of the nested formulas.

-LB
 
I tried the above code but it still show the comma at the end.
 
Then you need to show the content of each formula. Can some of the results be null? Or blank?

-LB
 
pectin,

Perhaps there is a space (or multiple spaces) after the final comma.

To borrow LBass's solution from above:
Code:
stringvar x := [b][COLOR=blue]TRIM[/color][/b]({@Visit Type - Email}+' '+{@Visit Type - No Contact}+' '+{@Visit Type - Supervised}+' '+{@Visit Type - Letter}+' '+{@Visit Type - Phone Call}+' '+{@Visit Type - Unsupervised Visits});
if len(x)>1 then
left(x,len(x)-1)

This should then trim the spaces off both the front and end of the string.

Hope this helps!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
You might be right. I didn't notice the trimleft vs. trim! I would try that first before spelling out all the formulas.

-LB
 
Thanks so much Ibass and MCuthill. It works perfectly!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top