control structure in crystal reports 8.5
i was trying to execute this algorithm:
for x = 0 to 10
x <-- this part should print the value
i was expecting that in the report, it will display the numbers 0 to 10 but it only displays the last value
i was hoping to use this in my recordset containing date range. in my recordset, not all the dates are included (e.g. 01/01/2006 - 01/05/2006 and the available dates are that of 1,3,5). i need to print all the dates in the range.
is there any way to do this?
Re: control structure in crystal reports 8.5
Yes.
You have to do this (BTW Not tested, just off the top of my head)
Create a local variable in the formula box
do you loop and concatenate the value on the variable
at the end, put formula = variable.
eg: using Basic format in the formula field
Dim a as string
for x = 0 to 10 step 1
a = a & toText(x)
loop
formula = a
That should do it.
Re: control structure in crystal reports 8.5
Quote:
Originally Posted by King_George
Yes.
You have to do this (BTW Not tested, just off the top of my head)
Create a local variable in the formula box
do you loop and concatenate the value on the variable
at the end, put formula = variable.
eg: using Basic format in the formula field
Dim a as string
for x = 0 to 10 step 1
a = a & toText(x)
loop
formula = a
That should do it.
thanx for the help.
tried it but it returned an error: "formula cannot call itself directly or indirectly" or sumthing like that.
going back to your example, instead of concatenating it, i need to insert a carriage return after each value printed.
using your example:
0
1
2
3
4
5
thanx again for the help
Re: control structure in crystal reports 8.5
Quote:
Originally Posted by BenchBrat87
thanx for the help.
tried it but it returned an error: "formula cannot call itself directly or indirectly" or sumthing like that.
going back to your example, instead of concatenating it, i need to insert a carriage return after each value printed.
using your example:
0
1
2
3
4
5
thanx again for the help
Did you create a formula field and put the code I showed inside it? Remember that code will display what you tell it to display. The way I have it works for me on CR8.5.
I created a formula field, opened it up, added the code, saved it and then put the field on the report. Poof it showed exactly what I thought it would. Anyways if you want to put a line feed character, I can't check right now because I'm not at work, but it can be done. Check the help file for the carriage return code used by CR.
HTH