Link to home
Start Free TrialLog in
Avatar of jych
jych

asked on

Crystal Reports (4.6.1): String Concatenation in a formula

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
Avatar of jflemin
jflemin

Left ({Field1}+{Field2},254 )
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.
Avatar of jych

ASKER

What if the total VALID length is more than 254?  What should I do then?
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
Avatar of jych

ASKER

I like vbkeco's answer better.  How would you get the points?
ASKER CERTIFIED SOLUTION
Avatar of vbkeco
vbkeco

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial