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!

Concatenate/Create a Horozontal String 1

Status
Not open for further replies.

BTate

Programmer
Jan 30, 2001
23
0
0
GB
I am want to create a Horozontal String.

For example: Using one field(string) within it's own group section. Instead of viewing it in a layered approach view each record horozontally separated by commas.
Now: Want:
AAAA (AAAA, BBBB, CCCC)
BBBB
CCCC
I know how to do this with more than one string and tried creating a formula using the next operator but no luck.

I'm open to all sugestions.

Thanx
Bryan
 
You need to create a running total that concatenates:

Something like:

WhilePrintingRecords;
STringVar combo;
Combo := Combo + {your field}

You need two more formulas to reset the formula at the beginning of each group, and one to display the results at the end of the group. Very similary to the 3-total technique mentioned in the FAQ on running totals. This is a running total of strings. Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
 
Ken

Thanx for you help, l've created the string running total but another problem has arisen. These are my 3 formulas

//Reset within previous group header
WhilePrintingRecords;
STringVar combo;
Combo := " ";

//Combo within Group header
WhilePrintingRecords;
STringVar Combo;
Combo := Combo + "(" + {@Grp3}+")"

//Display within Group footer
WhilePrintingRecords;
STringVar Combo;
Combo;

The result is adding the next string within brackets but I am still getting the layered view. Therefore what l need to do is suppress the previous rows and only show the final row.
Is this possible using the group format Suppress else what formula should l create?

Thanx
Bryan
 
Where are you displaying it? If you let the variable accumulate its various pieces of text in the details line and then suppress the details and only display the variable in the group footer, you shouldn't have a problem.
 
Dond12

When l stick my displat formula in the detailed section l get a 255 Character Error.
Is there a way to only display the last record e.g. onlastrecord operator

Thanx
Bryan
 
Display goes on the Group Footer to show the result. Hide the Group Header and Details.

If the string for one group will go over 255 (anywhere in the report) you will not be able to use this technique with one formula. Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
 
Ken

I've put the various formulas in there correct sections and the report runs without the 255 error.

The Display formula is generating what l want to see but on the final line of my group.
Therefore l only want to view last record.

E.g. Now Displays: AAAA Want: AAAA(BBBB)(CCCC)
AAAA(BBBB)
AAAA(BBBB)(CCCC)

I was thinking of using either Evaluate after or OnLastRecord functions?
 
Place the display on the group footer only.
When you put the display formula on the group footer you will only see the value from the last record of the group. Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
 
Ken

Thank-you vey much the problem is solved.

Cheers
Bryan
 
I have used this technique, and added one variation. In my report, I want a list of cities, each separated by a comma. Obviously, I don't want the last one to be followed by a comma, nor do I want a city to be followed by a comma if it's the only thing listed.

In other words, I want this kind of display:

Philadelphia
Chicago, Springfield, Rockford
Boston, Woburn

This is the formula that I insert in the details line (the details line is suppressed:

shared numbervar counter ;
shared stringvar cities ;
whileprintingrecords ;
cities := cities +
if(counter > 0) then ", " + {Apps.CITY}
else
{Apps.CITY}

The variable COUNTER is reset to zero in each group header. The variable CITIES is reset to "" in each group header. This is taken care of in a single formula called RESET:

whileprintingrecords ;
shared stringvar cities := "" ;
shared numbervar counter := 0 ;

The variable COUNTER is incremented by one with each item listed in the details section:

shared numbervar counter ;
whileprintingrecords ;
counter := counter + 1 ;

The technique works extremely well.
 
Thanx for the help with the comma, it's good to now if the user wants to
I've re-run my report and a slightly different error is coming up.
The values are presented as l would like to see but????

When the record grows to over a certain size l get the 254 Character Error.

Thinking of a solution:

Is there a way to convert or else set the display formula field up as a MEMO field instead of a text box?

 
Was meaning converting the current String field into a memo field?
 
You can't work with memo's in formulas.

However, if you can split the values into two or three different types, you can use two different formulas and variables. When they are complete, you can drop both formulas into the same text box to append one to the other. When you put several formulas into a text box there is no size limit. Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
 
I've followed this thread because I also need to print things horizontally instead of the layered view.

Here's the code:

In the group header:
----------------------------------------------
whileprintingrecords;

stringvar ResourceList;
shared stringvar array ResourceArray;
shared numbervar counter;

redim ResourceArray[ 100];
counter := 0;
That code initializes the array of things that get concatenated (ResourceArray) and the index for that array (counter).
----------------------------------------------
In the details:
WhilePrintingRecords;

shared stringvar array ResourceArray[ 100];
shared numbervar counter;

counter := counter + 1; ///increment counter
ResourceArray[ counter] := {OPRES.RESOURCE_ID}; ///store

------------------------------------------------
In the group footer:
whileprintingrecords;

stringvar ResourceString;
///the thing that will be printed
shared numbervar counter;
///the number of resource ids that have been stored

shared stringvar array ResourceArray[ 100];
///the array where the resource ids have been stored

numbervar temp := 1;
/ //temp counter for storage (loop *counter* times)

stringvar line := "";
///line to go into ResourceLines( linecounter)

for temp := 1 to counter do
/// for each item in the ResourceArray
if length ( line) > 200 then
///check length of line, if too long then
(
line := ResourceArray[ temp];
///reset the line to build
)
else
(
line := line + " ... " + ResourceArray[ temp];
/// otherwise, add to the existing line
);

line /// string returned (and printed)
-----------------------------------------

Everything is just lovely, except that I'm also getting the layered stuff. But, if I hide or surpress the detail line, I get "A subscript must be between 1 and the size of the array."

I'm stuck. Does anyone have any ideas?

Thanks!
Lynn
 
You can't suppress the details, because it won't run the subreport. Does the subreport have to be for every detail? There is no way to hide a detail subreport. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
The data file is set up so that each Op_Number may have 1-to-many Resource_Id records. I'm sorting by Op-Number within date.

I guess I'll chalk this one up to experience. Maybe I can put each resource in its own column on the detail line by calculating the column in which it belongs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top