Crystal Reports (4.6.1): String Concatenation in a formula

jych
jych used Ask the Experts™
on
I have a Crystal Report where I have a Formula field.  The formula field simply concatenates two text fields from the database. My function bombs when the total length of the concatenated string goes beyond 254.  I get an error saying that string cannot be more than 254 characters.  How can I solve this problem?

An early response would be greatly appreciated.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Left ({Field1}+{Field2},254 )

Commented:
You need to first check the length of each field in your Crystal Report.  In jflemin's example, if their combined length is greater than  254 characters you'll lose some data from Field2.  If that happens, try trimming the blanks off the end of each field first, check the new field lengths, then combine them.

Author

Commented:
What if the total VALID length is more than 254?  What should I do then?
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Commented:
You still need to know the TOTAL length of the fields.  Lets say, for example, that the total length of each field is as follows:

Field1 = 175 characters long, and
Field2 = 200 characters long.  

Their combined total is 375 characters.

Use the following statements in your subroutine:

Dim Field1 as String * 175
Dim Field2 as String * 200
Dim NewField as String * 375

NewField = Field1 + Field2

Hope it works!
vbkeco

Author

Commented:
I like vbkeco's answer better.  How would you get the points?
Commented:
Thanks jych, I assume it fixed your problem?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial