INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS
Come Join Us!
Are you a Computer / IT professional? Join Tek-Tips now!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- One-Click Access To Your
Favorite Forums
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site

(Download This Button Today!)
Feedback
"...I frequent other newsgroups, too, and am MOST IMPRESSED with the lack of smart a-- and presence of genuine desire to help anyone of any skill level..."
Geography
Where in the world do Tek-Tips members come from?
|
Numbering in Crystal Reports
|
|
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 www.crystalkiwi.com/nlog.htm |
|
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 [i]) ;
Mid(Results,3)//Need to remove first CR/LF
Thanks, Tej. |
|
|
Madawc (Programmer) |
2 May 12 6:51 |
I'd do it quite differently. First remove the final full stop (assuming it normally there, but this can be allowed for): CODE --> @Splittableif Right(({your.field}, 1) = "." then Left( ({your.field}, (Length({your.field})-1) else {your.field} Then something like CODEif 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. Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP
|
|
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. |
|
In the original code provided by Bruce, make sure you use i (not 1) in the ToText(i,0,... expression. - Ido view, export, burst, email, and schedule Crystal Reports. www.MilletSoftware.com |
|
I am using 'i' Ido, but the number is not increasing.
Thanks, Tej. |
|
|
lbass (TechnicalUser) |
2 May 12 21:34 |
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[i]+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 [i]) ;
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[i]+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
|
|
stringvar x := {myfield}; Local numbervar i; local stringvar array AllPoints := split(x,"<br/>"); local stringvar results :=""; for i := 1 to count(AllPoints) do ( Results := Results & ToText(i,0,"") + ". " + AllPoints[i]+chr(13) ); Results
data: Avai on a mo.<br />Incls Lel tions as ayed at Dn Sio.<br /><br />This option le at gn So only.<br />Must be ped for each ly and all va cabt mach.
Thanks, Krishna. |
|
in your data there is a space i didnt see before and didnt account for ... also... there is an additional <br /> which i didnt know was there and didnt account for so use this code with two changes ... 1 - I replaced <br /><br /> with <br /> so that the split function would not add a blank number (unless thats what you wanted) 2 - added a space in <br />.. i had it as <br/> stringvar x := replace({myfield},"<br /><br />","<br />"); Local numbervar i; local stringvar array AllPoints := split(x,"<br />"); local stringvar results :=""; for i := 1 to count(AllPoints) do ( Results := Results & ToText(i,0,"") + ". " + AllPoints[i]+chr(13) ); Results please copy that exatly with no changes and let me know if you get the desired results _____________________________________ Crystal Reports 2008 and XI Intersystems Cache 2012 ODBC connection
|
|
Now it is coming something weird. For some only "1." and for some 1,2,1,2,1,2...
Thanks for all the help CoSringsGuy, seems this is something i need to talk to db people and ask them to validate the data. Even I was spending too much time to figure out this, but doesn't seems logic problem.
Thanks, Krishna. |
|
odd _____________________________________ Crystal Reports 2008 and XI Intersystems Cache 2012 ODBC connection
|
|
|
lbass (TechnicalUser) |
5 May 12 18:03 |
Why are you using <br/>? What results do you get with the following? It works for me.
stringvar x := {yourfield}; 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[i]+chr(13) ); if right(x,1)='.' then left(Results, len(results)-len(totext(i,0,"")+'.')-2) else Results;
-LB |
|
Hi all,
I used the 'Record Number' special field and my issue is solved. Thanks for all the help. I learnt some new things with the codes you all provided.
Thanks, Tej. |
|
so I can learn something .... what do you mean by "I used the 'Record Number' special field and my issue is solved."? _____________________________________ Crystal Reports 2008 and XI Intersystems Cache 2012 ODBC connection
|
|
Hi CoSpringsGuy,
you know there will be crystal built in special fields like date time, page number etc. similarly there is one called 'record number'. i created a formula in basic syntax (not crystal syntax) in the formula editor as:
formula = totext(recordnumber,0) & ". " & Replace(Replace(Replace({myfield}, "<br/>", chr(13)), "< br/>", chr(13)))
Thanks, Tej. |
|
I'm not sure I understand how that could possibly be doing what I thought you were originally trying to do but I'm glad you got it figured out... _____________________________________ Crystal Reports 2008 and XI Intersystems Cache 2012 ODBC connection
|
|
|
lbass (TechnicalUser) |
7 May 12 16:59 |
Yes, I think that would just add a number at the beginning like this (for a field like "abcdabcdabcd.efghefhefh.ijklijklijkl."):
1. abcdabcdabcd efghefghefgh ijklijklijkl
I don't see how it would add a new number for each period.
-LB |
|
|
 |
|