Hi All,
I have a Crystal Report that has a group based on a formula. The formula in charge of creating the group looks something like this:
As you can see in the code, I have a database table with two fields: x and y. What this code does is it returns a unique value, 1, 2, or 3, for diferent combinations of the x and y fields of myTable. You could see in the code that when x is 10 and y is 20 or x is 30 and y is 40, the formula returns the number 1. Also, when x is 50 and y is 60, or when x is 70 and y is 80, the formula returns the number 2. Finally, when x is 90 and y is 100, the code returns the number 3.
Like I said before, in my report I have a Crystal Reports Group based on the above formula and the Crystal Reports engine automatically organizes the records in three groups: those for which the formula returns the number 1, those for which the formula returns the number 2, and those for which the formula returns the number 3.
Ok, all good so far. Now, when the report above prints, it will print in three pages. The first page will contain, of course, the records for which the formula returns 1, the second page will contain the records for which the formula returns 2, and the third page will have the records for which the formula returns 3.
Ok, still good. Now, I need to print a header for the each page. The header should say something like this:
X = 10, Y = 20 / X = 30, Y = 40
That would be the header for page 1. The header of page 2 would say:
X = 50, Y = 60 / X = 70, Y = 80
And so on... This way, users who view my report will know what each page means, duh. Well, I have a formula that does this: This formula is in is placed in the group header and it looks like this:
And here's where I have the problem. As you can see in the formula above, myX and myY are variables declared in the formula itself. They receive the values of myTable.x and myTable.y respectively. The variable outputValue is of type string and it should receive the value of the header that I want to print. The problem is that the formula can only access one value of x and y at a time so it prints only the first part of the header. For example, for page 1, the header should be
"X = 10, Y = 20 / X = 30, Y = 40"
but the formula only prints "X = 10, Y = 20". Of course, we know that for each group x and y have multiple values.
So, my question is: How can I read all the values of x and y in this formula so that the correct value of the header is printed?
Thanks
JC
We don't see things as they are; we see them as we are. - Anais Nin
I have a Crystal Report that has a group based on a formula. The formula in charge of creating the group looks something like this:
Code:
if (
({myTable.x} = 10 and {myTable.y} = 20)
or
({myTable.x} = 30 and {myTable.y} = 40)
) then [COLOR=red][b]1[/b][/color]
else if(
({myTable.x} = 50 and {myTable.y} = 60)
or
({myTable.x} = 70 and {myTable.y} = 80)
) then [COLOR=red][b]2[/b][/color]
else if(
({myTable.x} = 90 and {myTable.y} = 100)
) then [COLOR=red][b]3[/b][/color]
Like I said before, in my report I have a Crystal Reports Group based on the above formula and the Crystal Reports engine automatically organizes the records in three groups: those for which the formula returns the number 1, those for which the formula returns the number 2, and those for which the formula returns the number 3.
Ok, all good so far. Now, when the report above prints, it will print in three pages. The first page will contain, of course, the records for which the formula returns 1, the second page will contain the records for which the formula returns 2, and the third page will have the records for which the formula returns 3.
Ok, still good. Now, I need to print a header for the each page. The header should say something like this:
X = 10, Y = 20 / X = 30, Y = 40
That would be the header for page 1. The header of page 2 would say:
X = 50, Y = 60 / X = 70, Y = 80
And so on... This way, users who view my report will know what each page means, duh. Well, I have a formula that does this: This formula is in is placed in the group header and it looks like this:
Code:
numberVar myX = myTable.x
numberVar myY = myTable.y
stringVar outputValue
if (
myX = 10 and myY = 20
)then [b]outputValue = "X = 50, Y = 60"[/b]
[COLOR=green] // I don't know what do do to
// add the other part of the header[/color]
And here's where I have the problem. As you can see in the formula above, myX and myY are variables declared in the formula itself. They receive the values of myTable.x and myTable.y respectively. The variable outputValue is of type string and it should receive the value of the header that I want to print. The problem is that the formula can only access one value of x and y at a time so it prints only the first part of the header. For example, for page 1, the header should be
"X = 10, Y = 20 / X = 30, Y = 40"
but the formula only prints "X = 10, Y = 20". Of course, we know that for each group x and y have multiple values.
So, my question is: How can I read all the values of x and y in this formula so that the correct value of the header is printed?
Thanks
JC
We don't see things as they are; we see them as we are. - Anais Nin