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

Chr(13) Issue 2

Status
Not open for further replies.

munchen

Technical User
Aug 24, 2004
306
GB
I am using crystal 8.5.

I have an address field that displays data like so:

10 New Street
St Pauls
Bristol

Each line has a chr(13) after it. I want the field to be displayed on one line only with a comma separating the fields but no comma after the final line like so:

10 New Street, St Pauls, Bristol

I know the replace function will replace all occurrences of chr(13) with a comma but it places a comma after the last line if there is a chr(13) there like so:

Replace ({tblA.Address}, chr(13), ‘,’)
10 New Street,
St Pauls,
Bristol,

Any ideas how I can remove the chr(13) and make the address field appear on one line only with no comma after the last line?

Thanks in advance.
 
Try:

left(Replace ({tblA.Address}, chr(13), ‘,’),len(Replace ({tblA.Address}, chr(13), ‘,’))-1)

-LB
 
lbass

I tried your suggestion but alas it didn’t work. It didn’t keep any on one line like so:

10 New Street, St Pauls, Bristol

An address field can have one or more chr(13) after the last line.

For example there is one address that now displays like so (I will display the chr(13) just to clarify):

5 ABC Road,
Anywhere,
London,
,
,

I would like the above to be displayed like so:

5 ABC Road,Anywhere,London

Any ideas?
 
lbass

I meant to say that the address field can have 0, 1 or many chr(13) after the last line.

For example there is one address that now displays like so (I will display the chr(13) just to clarify):

5 ABC Roadchr(13)
Anywherechr(13)
Londonchr(13)
chr(13)
chr(13)

I would want this field to display like so:

5 ABC Road,Anywhere,London

Hope this explains things better.
 
Okay, then try this:

numbervar i := "";
stringvar x := replace({tblA.Address},chr(13),",");
stringvar array y := split(x,",");
numbervar j := ubound(y);
numbervar k := 0;
stringvar m := "";

for i := 1 to j do(
if y = "" then
k := k + 1;
m := left(x,len(x)-k));
m

-LB
 
Try:

join(split(replace(replace({tblA.Address},chr(13)+chr(13)+chr(13),""),chr(13)+chr(13),""),chr(13)),", ")

Should handle it.

-k
 
lbass & synapsevampire

Alas neither worked i'm afraid.

For lbass' suggestion I get an error saying a number is required here (on the 1st line numbervar i := "";).

For synapsevampire's suggestion depending upon the length of the field it is leaving a comma after the final line like so:

5 ABC Road,
Anywhere,
London,

and isn't putting the whole field on one line from eft to right like so:

5 ABC Road,Anywhere,London


 
Should have been:

numbervar i := 0;

I tested the formula, so it should work for you.

-LB
 
Then just add another test:

whileprintingrecords;
Stringvar MyString := trim(join(split(replace(replace({tblA.Address},chr(13)+chr(13)+chr(13),""),chr(13)+chr(13),""),chr(13)),", "));
if right(MyString ) = chr(13) then
left(MyString,len(MyString)-1)
else
MyString

-k
 
Dear munchen,

There is no vertical grow feature so you have to make sure to size the field the maximum length you think the field might be, otherwise it will wrap if you have the Can Grow feature checked.

Otherwise, either lbass or sv's solutions should be working for you. And, if it still doesn't work, I would suggest that you don't have chr(13) but perhaps chr(10) in the field.

regards,

ro

Rosemary Lieberman
rosemary-at-microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.

You will get answers more quickly if you read this before posting: faq149-3762
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top