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

> 254 Characters Error

Status
Not open for further replies.

groasa

Technical User
Jun 14, 2001
39
0
0
US
Crystal 8.5 (can't upgrade until next year)
SQL Server database connection through Pivotal dll.

The Invoice has multiple serial numbers listed for the order. I want to concatenate these serial numbers into one field, but I am running into the >254 characters limit.

From what I've read in the forums, I should be able to split it up somehow and then drop each formula into a text box. There was one example formula that created an array, but the variables were different types so I couldn't use the formula.

I'll include the formulas that I tried to copy from below. So, any help in getting the formulas right would be appreciated.

-Glenda
=====================================================
You would have an initialization formula in the Widget header

@Initialization (suppressed in Widget header)

WhilePrintingRecords;
if not InRepeatedGroupHeader then
(
StringVar array SerialNumbers := ["","",""];
NumberVar Pointer := 1;
);

Now suppress the details section and put the following formula inside it
***************************
@CollectSerialNumbers

WhilePrintingRecords;
StringVar array SerialNumbers ;
NumberVar Pointer;

If Pointer = 1 then
(
if length(SerialNumbers[1] + {Table.SerialNumber}) < 254 then
SerialNumbers[1] := SerialNumbers[1] + {Table.SerialNumber}
else
Pointer := 2;
);

If Pointer = 2 then
(
if length(SerialNumbers[2] + {Table.SerialNumber}) < 254 then
SerialNumbers[2] := SerialNumbers[2] + {Table.SerialNumber}
else
Pointer := 3;
);

If Pointer = 3 then
SerialNumbers[3] := SerialNumbers[3] + {Table.SerialNumber};
*************************************

Now In the footer for Widgets create 3 subsections

In the three subsections you put the fields like this

{Product} { Widget} {@DisplaySerialNo1} sec (A)
---------------------------------------------
{@DisplaySerialNo2} sec (B)
---------------------------------------------
{@DisplaySerialNo3} sec (c)

The formulas above are simple


DisplaySerialNo1

WhilePrintingRecords;
StringVar array SerialNumbers ;

SerialNumbers[1] ;

***********************
DisplaySerialNo2

WhilePrintingRecords;
StringVar array SerialNumbers ;

SerialNumbers[2] ;

***********************
DisplaySerialNo3

WhilePrintingRecords;
StringVar array SerialNumbers ;

SerialNumbers[3] ;


MAKE SURE THE BORDERS OF THE SECTIONS ARE SNUGGED TIGHT TO THE BOTTOM OF THE Fields...and MAKE SURE THE "CanGrow" is enabled on each dispaly field and that "SUPPRESS Blank SECTION" is enabled in the section expert for each Widget footer section.
 
You could use the Left and Mid commands to chop the field up into arbitrary chunks. Drop these chunks into a text box and they should be OK.

Madawc Williams (East Anglia)
 
Why don't you bother to post the data types you're using instead of complaining that they're different from the example?

"There was one example formula that created an array, but the variables were different types so I couldn't use the formula."

If you have numeric serial numbers, use the above suggestion only convert your serial numbers using:

totext({table.field},0,"")

-k
 
I apologize for complaining. I must have been unclear. My data types are not different from the example. When I replace my database fields directly into the formula as delineated in the example, I get the error: "A string is required here." Once I click OK on the error, the cursor is blinking immediately to the left of this line: "Pointer := 2"

According to the Crystal Reports Online Help:
The Then and the Else parts, however, must both be of the same data type: (Then text, Else text; Then number, Else number). Mixing text and number actions will result in an error message.

And unless, I'm reading it incorrectly (which is entirely possible as I am sure that I am lacking in expertise), would the StringVar and the NumberVar that are declared in this formula be different data types?

example field my database
=========== ===========
SerialNumbers Dongles
{Table.SerialNumber} Dongle_Product_Config.Dongle Number}
Pointer Pointer

Here is the error message and the exact formula as I have entered it into the formula editor:
254error.jpg


I'm still leaning towards the concept of the example, however, apparently, I must be misinterpreting something so that it is giving me an error message. If anyone could help me work through my errors, I would be much obliged. In the meantime, I'm going to also try the Left and Mid commands to see how that works.

Thank you all for your continued assistance.
-glenda :eek:)
 
Hi;

It seems to me that you are concatenating integer values with varchar values.

Use Cstr( { Dongle_Product_Config.Dongle Number} )

I hope it would work.

Thanks.
 
To restate my previous post, and reiterating Apexbs's thought, convert the values, you can't combine a numeric and a string unless you convert it or use &, as in:

Dongles[1]+totext({Dongle_Product_Config.Dongle Number},0,"")

or more simply:

Dongles[1] & {Dongle_Product_Config.Dongle Number}

Again, you are trying to combine different data types using +, the & supports this, or you can convert it and use the formatting options.

totext({Dongle_Product_Config.Dongle,<number of decimal places>, <thousands delimiter>)

Hope this resolves.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top