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

Repeating same data in Crystal report

Status
Not open for further replies.

bb25

Programmer
Mar 2, 2004
8
SG
Hi everyone.

I have a problem here.
Hope someone can help me out.

I've created a report using CR8.5 and in this report, there is a field which may contain either 1 or more values.
The scenario is like this:
For every treatment signed by the customer, at least 1 product will be used together. I need to print out the treatment in 1 line, and the product code(s) will follow in the same line. So i may have something like this:

treatmentid product1(price)/product2(price)/product3(price)...

can anyone tell me how I can repeat the product/price field within the same line?

.Thanks/
 
hi
Use a text box and insert the fields in them like this


treatmentid+ product1+"("+price+")"+"/"+product2+"("+price+")"+"/"+
product3+"("+price+")"

hope this helps



pgtek
 
Group on {table.treatmentid} and then create these formulas;

//{@reset} for the group (treatment) header:
whileprintingrecords;
stringvar prodprice := "";

//{@accum} for the details section:
whileprintingrecords;
stringvar prodprice := prodprice + {table.prod}+"("+
totext({table.price})+")/"

//{@display} for the group footer:
whileprintingrecords;
stringvar prodprice;
left(prodprice,len(prodprice)-1);

Drag the groupname into the group footer and then suppress the group header and details section.

-LB
 
Hi all.. thanks for all your help..still got problem though

pgtek:

Your method may not be very suitable as I do not know at all how many products will be used in a single treatment. It can range from 1 product to maybe 10 or more.. so its not really feasible.

As for the 2nd method by LB:
I get an error here:
stringvar prodprice := prodprice + {out_product.PRODUCT_CODE}+"("+totext({out_product.PER_UNIT_SP}*{out_product.QTY})+")/"

"max characters is 254"

Help me pls.. its quite urgent.. :(
 
Part of the problem is you are forcing us to guess the look.

Each variable/formula can handle only 254 chars so you could modify Lbass's formulas as follows:

I will ASSUME that the number of characters in {table.prod}+"("+ totext({table.price})+")/" is 20...therefore before you add a group to a string there must be at least 234 chars max in the string


//{@reset} for the group (treatment) header:
whileprintingrecords;
stringvar prodprice1 := "";
stringvar prodprice2 := "";

//{@accum} for the details section:
whileprintingrecords;
stringvar prodprice1;
stringvar prodprice2;

if length(prodprice1) < 234 then
prodprice1 := prodprice1 + {table.prod}+"("+ totext({table.price})+")/"
else
prodprice2 := prodprice2 + {table.prod}+"("+ totext({table.price})+")/";

the display of the results will be done in 2 subsections of the Group footer

//{@displayprodprice1} for the group footer subsection (a):
whileprintingrecords;
stringvar prodprice1;

left(prodprice1,len(prodprice1)-1);

//{@displayprodprice2} for the group footer subsection (b):
whileprintingrecords;
stringvar prodprice2;

left(prodprice2,len(prodprice2)-1);


In the conditional suppress for the Group Subsection (B) would have the formula

whileprintingrecords;
stringvar prodprice2;

prodprice2 = "";


If there are more than 308 chars to the total for a group then you can similarly add another variable....but seriously think you should review the look of the report if it is.


Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
The following will allow for string up to 762 characters in length. Change {@accum} to:

whileprintingrecords;
stringvar prodprice;
stringvar prodprice2;
stringvar prodprice3;

if prodprice2 = "" then
(if len(prodprice3) + len({out_product.PRODUCT_CODE}+ "("+totext({out_product.PER_UNIT_SP} * {out_product.QTY})+ ") / ") > 254 then
prodprice2 := prodprice2 + {out_product.PRODUCT_CODE}+"("+totext({out_product.PER_UNIT_SP}*{out_product.QTY})+") / " else
prodprice3 := prodprice3 + {out_product.PRODUCT_CODE}+"("+totext({out_product.PER_UNIT_SP}*{out_product.QTY})+") / " ) else
if prodprice = "" then
(if len (prodprice2) + len({out_product.PRODUCT_CODE}+"("+totext({out_product.PER_UNIT_SP}*{out_product.QTY})+") / ") > 254 then
prodprice := prodprice + {out_product.PRODUCT_CODE}+"("+totext({out_product.PER_UNIT_SP}*{out_product.QTY})+") / " else
prodprice2 := prodprice2 + {out_product.PRODUCT_CODE}+"("+totext({out_product.PER_UNIT_SP}*{out_product.QTY})+") / ") else

(if len(prodprice) + len({out_product.PRODUCT_CODE}+"("+totext({out_product.PER_UNIT_SP}*{out_product.QTY})+") / ") > 254 then
prodprice := prodprice else
prodprice := prodprice + {out_product.PRODUCT_CODE}+"("+totext({out_product.PER_UNIT_SP}*{out_product.QTY})+") / ";

Then create three display formulas:

//{@displprodprice}:
whileprintingrecords;
stringvar prodprice;
left(prodprice, len(prodprice)-2); //this removes the final slash

//{@displprodprice2}:
whileprintingrecords;
stringvar prodprice2;

//{@displprodprice3}:
whileprintingrecords;
stringvar prodprice3;

Then drop these into a text box in the group footer, in reverse order: prodprice3, prodprice2, prodprice1. Make sure the text box is formatted with "Can Grow." I added in spaces before and after the "/'s" to allow for more continuous wrapping in the text box.

If you have the potential for more than 762 characters you would need to adapt the formula further (or else upgrade to 9.0), since it now "stops" after 762 characters.

-LB
 
Hi all.. i did as what is advised but problems still occur.
But eventually, managed to get something up by formatting the details section into columns...
Not as nice visually, but good enough for the moment, till I figure out the codes that you guys gave.. thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top