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

Capturning Field Values

Status
Not open for further replies.

TEM3

Technical User
Dec 6, 2004
324
US
Using CR 8.5/Oracle Tables:

I have records grouped by transaction dates. I wish to display the item numbers of those records horizonally. In other words, instead of:
1
2
5
8
9

I want to display the field {item number} in each group as:

1,2,5,8,9

Can I read the contents of the item number field of each appropriate record into a formula somehow and cancatenate them to print horizontally as above? If so, some example code would be great.

If there is an easier/better way, please let me know.
 
Assuming that they're numeric, we'll use the 3 formula method:

Group Header Formula:
whileprintingrecords;
stringvar MyValues:=""

Details Formula:
whileprintingrecords;
stringvar MyValues:=MyValues&totext({table.field},0,"")&",";

Group Footer Formula:
whileprintingrecords;
stringvar MyValues;
Left(MyValues,len(MyValues)-1)

-k
 
Actually, they are not numeric, but that should not be a problem. I will adjust your formula accordingly and try it. Thanks once again.....
 
Using the following set of formulas and playing around as to which Group header/footer they would reside in, it worked perfectly!

//Group Header Formula

whileprintingrecords;
shared stringvar MyValues := "Items # "

//Details Formula

whileprintingrecords;
shared stringvar MyValues := MyValues & (trim({LABITEM.Lab Item Number}) & ", ");

//Group Footer Formula

whileprintingrecords;
shared stringvar MyValues;
Left(MyValues,len(MyValues)-2)

Now, a formatting question.....

Since the list of items (MyValues) can get pretty long and span three lines or more, is there a way to set the text box in the Group Footer to "grow", like you can in a details section text box? I hate to have a one line "MyValues" take up the same report space as a four line "MyValues"!
 
Why aare you using a text box since this is a formula?

Just place the formula in the group footer and select Can Grow under the options.

-k
 
OK, must have missed it. Since it is text, it is acting as a text box.......
 
You would have saved yourself a good deal of time by just being specific in the beginning, such as stating the data types.

A common occurence with posts is to try to describe with text instead of posting technical information, think of posting as creating a mini-spec, you would have gotten the proper formulas the first go around.

Glad it worked out.

-k
 
Yes, and I found the "Can Grow" check box I did not find before. Again, thank you!

New problem though.....

Apparently there are a few worst-case Cases that have so many items, I get the "A string can be at most 254 characters long" error message.

Time to learn some Crystal Reports error trapping.....

Any additional suggestions??
 
I guess I could do something like:

//Details Formula
shared stringvar MyValues;
shared stringvar MyValues2;

whileprintingrecords;

if len(MyValues) < 240 then
MyValues := MyValues & (trim({LABITEM.Lab Item Number}) & ", ")
else
MyValues2 := MyValues2 & (trim({LABITEM.Lab Item Number}) & ", ");

I would initialize and display both MyValues and MyValues2.....

 
hmmm, TEM3, maybe you could use a Cross-Tab thingy to arrange your records with your item numbers horizontally?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top