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!

Removing the last character in a string

Status
Not open for further replies.

leftfldr

Programmer
Mar 30, 2005
23
US
Using Crystal 10 with Microsoft SQL Server 2000 backend and a Microsoft Dynamics ERP solution.

I have a report that is generating labels based on ship to addresses for customers. Customer Number is GH1 and Address Code is GH2. The label contains the customer name and all contacts associated with that customer/address code.

I have three formulas to get the contact names and separate them by a comma.

@rtcontact - in Details
WhilePrintingRecords;
stringvar contact;
if length(contact) > 235 then contact:=contact
else contact:=contact + {CSC43102.CNTCPRSN} + ", "

@reset - in GH2
WhilePrintingRecords;
stringvar contact:= ""

@display - in GF2
WhilePrintingRecords;
stringvar contact;
contact;

The problem is that it is putting a comma at the end too.
EX.
ABC Company
Attn: John Doe, Jane Doe, Liz Doe,

How can I elminate the last character if it is a comma? I have tried the instr and right funcions but not sure if it is not working because it is a variable?

I appreciate the help in advance!
 
leftfldr,

try:

@display - in GF2
WhilePrintingRecords;
stringvar contact;
left(contact,len(contract)-1);

Andy
 
Using:

@display - in GF2
WhilePrintingRecords;
stringvar contact;
left(contact,len(contract)-1);

It still prints a comma at the end. What am I missing?
 
It looks like you have a comma then a space at the end, so you will need to remove the last 2 characters:

@display - in GF2
WhilePrintingRecords;
stringvar contact;
left(contact,len(contract)-2);

~Brian
 
Oh PERFECT! Thanks so much for the help. It's always the little simple things that you get caught up on :)!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top