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

crystal reports array 2

Status
Not open for further replies.

calandhob

Programmer
Jul 5, 2004
1
CA
Im using crystal reports 8.5 . In the Detail section of the report im creating a string, which i concatenate with each record
eg
SHARED STRINGVAR NAMES;
NAMES := NAMES + {TABLE.NAME} + ", ";

Then i print the values in the report footer. The problem i run into is when the length of the string > 254, then i get an error.
I was thinking of using an Array to do this. Can anyone show me how i should proceed with this ( How to Print an Array ??)

Any help is appreciated.
 
You have run into a limitation of crystal v8.5 and lower. Upgrade to crystal v9 or higher and you will have 64,000 characters to do this.

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
Basically, I can show you how to put your values into an array, but, once again, you are going to be faced with the same issue when you come to print the contents back out again.

Max length of a string variable in CR8.5 & earlier is 255 as stated.

One alternative could be when you come to print it out, you have to create multiple variables, each 255 chars long. Of course, these can't be dynamic, such that you would need to know how many such variables to create & create them at design time. Pretty ugly really.

You haven't mentioned what DB. Another option might be to create a field (Memo) on the DB (Stored Procedure) & bring that back, which CR8.5 will happily display, but you can NOT use it in a formula at all.
 
I have just run into a similar problem. I am trying to use a stringvar to hold city names concatenated together to hold a unique sting for each load shipped out in a unique pattern to cities.

For example a load going to Cleveland, then Columbus, and then Cincinnati would become ClevelandColumbusCincinnati.

I only see this example as 27 characters. Am I misunderstanding how it is counting "characters"? The largest we would have would be around 60 characters. But I get the error "a string can be at most 254 characters long".

Thanks for any help.
 
You should start a new post, old posts don't get as much action.

You should also supply technical information for better results:

Crystal version
Database/connectivity used
Example data
Expected output

If you're getting the 254 character message than it's exceeding 254 characters.

Try posting what you used (rather than trying to describe it with words), and where you used the formula.

Presumably you're grouped by the Shipment/Load, so you'd need 3 formulas to display it for each Shipment:

Group Header:
whileprintingrecords;
Stringvar TheSites:=""

Detail:
whileprintingrecords;
// concatenate the cities
Stringvar TheSites:=TheSites+trim({table.city})+" "

Group Footer:
whileprintingrecords;
Stringvar TheSites;
trim(TheSites)

Note that I trim the city field just in case it's padded with spaces.

-k
 
Sorry for the lack of info.
Crystal 8.5
Oracle 9

I believe I have what you suggested, but I will double check my logic.

But am I correct in the assumption that each letter in a string is 1 character. For example the word "cleveland" has 9 characters?

Thanks
 
Yes, that's correct.

You can use the following formulas to check what's happening in the details section:

Group Header:
whileprintingrecords;
Numbervar LenSites:=0

Detail:
whileprintingrecords;
Numbervar LenSites:=LenSites+len(trim({table.field})

Group Footer:
whileprintingrecords;
Numbervar LenSites

Now you can see how it's growing in the details and get the total length in the footer.

-k
 
This report is a mess, I'm trying to fix it for someone else. There are 3 different groupings, and the detail is actually printing in one of the footers. I must be resetting the string in the wrong place. That was obvious when I started displaying the sting for every record, it just kept growing. Thanks for the help.
 
The formula is working the way it should (ie growing with each record) You have to put the formula into the section that contains the information so that it accumulates the information. What you need to do is suppress the field.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top