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!

Numbering in Crystal Reports

Status
Not open for further replies.

krshtej

MIS
Jan 3, 2011
22
US
Hi,

I have a text field which is a paragraph of notes. I want to display it as point.

ex:
abcdabcdabcd.efghefhefh.ijklijklijkl.

display:
1. abcdabcdabcd
2. efghefghefgh
3. ijklijklijkl

Thanks.
 
Local numbervar i;
local stringvar array AllPoints := split({table.field},".");
local stringvar results :="";

for i=1 to count(AllPoints)
Results := Results & char(13) + char(10) +
ToText(i,0,"","") + ". " + AllPoints [ i];

Mid(Results,3) //Need to remove first CR/LF

Bruce Ferguson
 
Thanks Bruce, it worked. But thing is the number is not increasing, only '1.' is coming in front of all the points. How to increase the 'i' value.

Thanks,
Tej.

 
Sorry Bruce, I think i dint check the can grow option. Its good now.

Thanks,
Tej.
 
Hi Bruce,

I have edited the code as per my needs and this is how it is now. But the number is not repeating (even when i changed it to 'can grow'), it is always '1.'

Local numbervar i;
local stringvar array AllPoints := Replace(Replace(Replace({table.field}, "<br/>", chr(13)), "< br/>", chr(13)), "<br />", chr(13));
local stringvar results :="";

for i:=1 to count(AllPoints)
do (Results := results & chr(13) & chr(10) + ToText(i,0,"","") + ". " + AllPoints ) ;

Mid(Results,3)//Need to remove first CR/LF


Thanks,
Tej.
 
I'd do it quite differently. First remove the final full stop (assuming it normally there, but this can be allowed for):
Code:
if Right(({your.field}, 1) = "."
then Left( ({your.field}, (Length({your.field})-1)
else {your.field}

Then something like
Code:
if ubound(@Splittable, ".") = 3
then "1. " & Split(@Splittable, ".")[1]
   & "2. " & Split(@Splittable, ".")[2]
   & "3. " & Split(@Splittable, ".")[3]
else ...

And so on for all possibilities. Long-winded, but not too much work with cut-and-paste. And using formula fields within formula fields is usually better than working with variables within Crystal.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
Hi Madawc,

I tried but, this code is not working for me. Also the points will be variable, I cannot hard code it to 3. The one i specified above is giving me all I need except that the number is not increasing. Any help?

Thanks,
Tej.
 
I am using 'i' Ido, but the number is not increasing.

Thanks,
Tej.
 
stringvar x := {table.field};
Local numbervar i;
local stringvar array AllPoints := split(x,".");
local stringvar results :="";
for i := 1 to count(AllPoints) do (
Results := Results &
ToText(i,0,"") + ". " + AllPoints+chr(13)
);
Results

-LB
 
Hi LB,

Now numbers are not coming at all in front of the points.

Thanks,
Tej.
 
I tested LBs formula and it worked perfectly except that if there is a period at the end of your field string you will get an extra number.. with your example the output would be

1. abcdabcdabcd
2. efghefghefgh
3. ijklijklijkl
4.

if your field ALWAYS has a period at the end modify LB suggestion as follows
change for i := 1 to count(AllPoints) do
to for i := 1 to count(AllPoints)-1 do



_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 
Hi CoSpringGuy,

I am using this as the end of points is having '<br/>'.

Local numbervar i;
local stringvar array AllPoints := Replace(Replace(Replace({table.field}, "<br/>", chr(13)), "< br/>", chr(13)), "<br />", chr(13));
local stringvar results :="";

for i:=1 to count(AllPoints)
do (Results := results & chr(13) & chr(10) + ToText(i,0,"","") + ". " + AllPoints ) ;

Mid(Results,3)//Need to remove first CR/LF

but problem is number is not repeating, it is always showing '1.'

Thanks,
Krishna.

 
Hi Krishna,

The one thing that I see you consistently doing when replying is changing the array assignment. Notice the other suggestions you have received have populated the array using the the split function. Without that (or some other method) you are only populating one element of the array. you could change it to a straingvar rather than an array and get the same results you are getting. Have you actually tried the EXACT code LB suggested?


Maybe if you provide an example of exactly what the data string looks like that you are working with? I thought that was what you did in the first post but if you are saying that code doesnt work then maybe you didnt?

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 
I think I know what you meant by <cr/> now ... try LBs solution again with a few modifications...

stringvar x := {table_field};
Local numbervar i;
local stringvar array AllPoints := split(x,"<br/>");
local stringvar results :="";
for i := 1 to count(AllPoints)-1 do (
Results := Results &
ToText(i,0,"") + ". " + AllPoints+chr(13)
);
Results

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 
Hi CospringsGuy,

I can see the problem, that it is storing only one point that's why loop is not running and displaying only '1.' But how to make the point get stored in the array. I have tried the LB's code also yours, using the split but same thing only '1.' is coming.
I am using replace because i have observed that points are stored in the my field as
abcdabcd<br/>efghefgh<br/>.....

Thanks,
Krishna.
 
then use the code i sent in the last message....

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 
don't change anything about it except the name of your field. if your "points" are broken by <br/> then that code will work.. I already tested it before I put it up here. if it doesnt work then paste the exact code of your formula AND an exact sample of the data stored in the field from the table.

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 
Hi CoSpringsGuy,

When I am using you code(with just field name)nothing is coming. So, i removed the -1 (count(AllPoints)-1) and results are coming but number coming always "1.". Just to let you know i am using this in subreport (details section). This subreport is placed in the main report's group header. (I don't know if this information helps.)

Thanks,
Krishna.
 
Again -

Please post your formula exactly as you have it and some data from your field

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top