• Status: Solved
• Priority: Medium
• Security: Public
• Views: 97

# Crystal Reports Numbering a Line Wrapping

I have a field that is set-up as 'Can Grow'.  Is it possible to number the line when it wraps?
Accounting wants something like this:
\$1\$One Million Seven Hundred Seventy-Seven Thousand Seven Hundred
\$2\$Seventy-Seven and 77/100
This is a field in a print-out of a check run and a large amount check will not fit on one line.
0
slmc
• 4
• 2
1 Solution

Commented:
How are you generating the text?

mlmcc
0

Author Commented:
uppercase (ToWords ({CASH_DISBURSEMENT.AMOUNT}))
0

Commented:
What is generated by the report now?

Try this formula

``````Local StringVar NumberText;
Local StringVar Array arrNumberText;
Local NumberVar Index;
Local NumberVar lengthNumberText;
Local NumberVar LineCount;
Local NumberVar ReportFieldWidth  := 35;

arrNumberText := Split(Uppercase(ToWords((({CASH_DISBURSEMENT.AMOUNT},2)));
NumberText := '\$1\$';
lengthNumberText := 3;
LineCount := 1;
For Index := 1 to UBound(arrNumberText) do
(

lengthNumberText := lengthNumberText + length(arrNumberText[Index]) + 1;
If lengthNumberText > ReportFieldWidth then
(
LineCount := LineCount + 1;
NumberText := NumberText & chr(13) & '\$' & CStr(LineCount,0) & '\$';
lengthNumberText := 3 + length(arrNumberText[Index]) + 1;
);
NumberText := NumberText & ' ' & arrNumberText[Index];
);

NumberText
``````

Change the 35 in the above code to the number of characters your field is wide minus 2.  You will probably have to test some numbers to get the one that works best.  It is better to be a little low on the count.  The number depends on the font you use and the font size.

In my testing I used a Courier 10 for the font.  Courier is fixed size font so there are 12 characters per inch.  The width was 3".  I first tried 35 for the count and my text wrapped in the middle of line 1.  Changed to 34 and it worked correctly.  I didn't try a lot of numbers in the test so run it against your data just to the screen and see what you get.

mlmcc
0

Author Commented:
That gives me exactly what I want.  Thank you very much
0

Author Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for slmc's comment #a40575915

for the following reason:

This does exactly what I want.
0

Commented:
You accepted your own post as the solution.  I assume that you meant to accept mlmcc's last post instead.  You can cancel the closing of the question and re-close the question.

James
0

Author Commented:
Exactly what I needed.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.