Crystal reports trimming spaces at the end of fields.

Hi,

I am placing multiple fields into a text box.  These each of these fields in the database contain a space at the end.  For some reason crystal reports is removing these spaces.  I need it to place a space between each of the fields.  I attempted to put a space in the text box between the fields, but if the field is blank it will leave two spaces.

Thanks
FTIISDAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
frodomanConnect With a Mentor Commented:
That's going to be tough to overcome with a text box because you have little or no control over how Crystal formats it.

I would consider instead creating a formula so you can control the results.  Something along these lines:

================================
stringVar MyResult := '';

If trim({table.field1}) <> '' Then
  MyResult := {table.field1};

If trim({table.field2}) <> '' Then
  MyResult := ' '+{table.field2};

If trim({table.field3}) <> '' Then
  MyResult := ' '+{table.field3};

...etc...

MyResult;

================================

0
 
frodomanCommented:
Sorry for the typo, should actually be:

================================
stringVar MyResult := '';

If trim({table.field1}) <> '' Then
  MyResult := {table.field1};

If trim({table.field2}) <> '' Then
  MyResult := MyResult+' '+{table.field2};

If trim({table.field3}) <> '' Then
  MyResult := MyResult+' '+{table.field3};

...etc...

MyResult;

================================
0
 
FTIISDAuthor Commented:
Is there any other way to do this?  Is there a reason that crystal reports is removing these spaces? I have an extremely long reports, and this method will take a long time.

Thanks.
0
 
frodomanCommented:
I have no idea "why" but it's not even consistent between versions.

How long your report is doesn't matter as much as how many fields you're combining into a single text box.  I don't know of an easier way to do this.  Honestly I usually just put the space between the fields and ignore the extra spaces when they happen - I use a variable width font so you have to really look closely to see the difference between one space and two anyway.


0
 
mlmccCommented:
The formula idea will work for CR9 and 10.  For earlier versions so long as the text doesn't exceed 255 characters it will work.

The inserting into a text box is the method for getting around the ength limitation.

I agree with frodoman, if single vs double space is important use the formula.

mlmcc
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.