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

String Length Problems

Status
Not open for further replies.

TEM3

Technical User
Dec 6, 2004
324
US
Using Crystal Reports 8.5:

Thanks to previous help from this group, I put together the following formula to concatinate item numbers to print them as a group horizontally:

//Details Formula
shared stringvar MyValues;
whileprintingrecords;

//if len(MyValues) < 240 then
if len(trim({CONTAINER.Container Description})) > 0 or isnull({CONTAINER.Container Description}) then
MyValues := MyValues & (trim({LABITEM.Lab Item Number}) & "(" & trim({CONTAINER.Container Description}) & ")" & ", ")
else
MyValues := MyValues & (trim({LABITEM.Lab Item Number}) & ", ");

If I comment out the len line (as I have done above), the report crashes with a "string cannot be longer than 254 characters" error. But I need to be able to print longer strings.

Suggestions?
 
Crystal 8.5 has a maximum output for formulas of 254 (CR 9 and above does not).

Your alternatives are to create numerous variables and output formulas for > 254 characters.

Also Crystal will ignore an isnull if it is not the first thing checked within a conditional.

Here's an example that should help:

//Details Formula
whileprintingrecords;
shared stringvar MyValues;
shared stringvar MyValuesContinued;

if len(MyValues) < 240 then
(
if isnull({CONTAINER.Container Description})
or
len(trim({CONTAINER.Container Description})) > 0 then
MyValues := MyValues & (trim({LABITEM.Lab Item Number}) & "(" & trim({CONTAINER.Container Description}) & ")" & ", ")
else
MyValues := MyValues & (trim({LABITEM.Lab Item Number}) & ", ")
)
else
if len(MyValuesContinued) < 240 then
(
if isnull({CONTAINER.Container Description})
or
len(trim({CONTAINER.Container Description})) > 0 then
MyValuesContinued := MyValuesContinued & (trim({LABITEM.Lab Item Number}) & "(" & trim({CONTAINER.Container Description}) & ")" & ", ")
else
MyValuesContinued := MyValuesContinued & (trim({LABITEM.Lab Item Number}) & ", ")
);

...etc...add more variables as required...

Now in the group footer you'd reference them using different formulas:

whileprintingrecords;
shared stringvar MyValues

whileprintingrecords;
shared stringvar MyValuesContinued;

This is just an example and may have syntax errors, at any rate you probably get the idae as you'vre already done the heavy lifting, I just added a variable for the next 254 characters...

-k
 
OK, with excellent help from "-k", the follow series of (4) formulas work:

//Group Header Formula

whileprintingrecords;
shared stringvar MyValues := "Item(s) # ";
shared stringvar MyValuesContinued := "";

/Details Formula
whileprintingrecords;
shared stringvar MyValues;
shared stringvar MyValuesContinued;

if len(MyValues) < 240 then
(
if isnull({CONTAINER.Container Description})
or
len(trim({CONTAINER.Container Description})) > 0 then
MyValues := MyValues & (trim({LABITEM.Lab Item Number}) & "(" & trim({CONTAINER.Container Description}) & ")" & ", ")
else
MyValues := MyValues & (trim({LABITEM.Lab Item Number}) & ", ")
)
else
if len(MyValuesContinued) < 240 then
(
if isnull({CONTAINER.Container Description})
or
len(trim({CONTAINER.Container Description})) > 0 then
MyValuesContinued := MyValuesContinued & (trim({LABITEM.Lab Item Number}) & "(" & trim({CONTAINER.Container Description}) & ")" & ", ")
else
MyValuesContinued := MyValuesContinued & (trim({LABITEM.Lab Item Number}) & ", ")
);


/Group Footer Formula

whileprintingrecords;
shared stringvar MyValues;

if len(MyValues) < 240 then
Left(MyValues,len(MyValues)-2)
else
MyValues;


//Group Footer Formula Continued

whileprintingrecords;
shared stringvar MyValuesContinued;

if len(MyValuesContinued) > 3 then
Left(MyValuesContinued,len(MyValuesContinued)-2);


Now, the problem is formatting this mess. The orginal MyValues prints in a "can grow" box. How can I format so that, where appropriate, MyValuesContinued will print seamlessly???


 
Drop both formulas into a text box. Make sure they snap into place, one after the other.

-LB
 
I will try the above.

I did drop MyValuesContinued into another Group Footer and suppress the section if the string is empty.......
 
Insert a text box and then drag the formulas into it.

Upgrading will save you this grief.

-k
 
Wish I could (upgrade). Our LIMS system has 8.5 embedded.
 
The text box technique worked perfectly! Thanks so much!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top