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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to process data in arrays in Group Footer

Status
Not open for further replies.

bikejockey

Programmer
Nov 1, 2002
15
US
CR version 9
As I process the records a group I build several arrays. In the group footer I need to process the data in the arrays, calling custom functions, etc. Printing results, etc.

Here is what I would like to do in a group footer
GFa - Initialize a global variable
GF1b - Print calculations based on the global variable
GF1c - modify the global variable
GF1d - Print calculations based on new value of global variable
continue process 5 times.

WhilePrintingRecords is set in all the formulas.

Any suggestions on how to get this to work.
 
It sounds like you want to use a loop. You don't need to explicitly state a global variable, that's the default.

whileprintingrecords; //GF1A
numbervar array MyArray := [1,2,3,4,5];
numbervar Counter;
For Counter := 1 to ubound(MyArray) do(
MyArray[Counter]:= MyArray[Counter]+100 // modify values
);

Now you can display these 5 values in formulas using something like:

whileprintingrecords; //GF1B
numbervar array MyArray[1]

Where the [1] is the subscript of what you need.

Since you didn't supply any examples of what's in the array, or what you intend to do with them, I opted for an overview.

If you wanted (or want) specifics, please post specific questions.

-k
 
Lets say I have the following formulas

InitailizeGlobalV
NumberVar GlobalV := 6

DecrementGlobalV
NumberVar GlobalV := GlobalV - 1

GlobalV
NumberVar GlobalV

In a GroupFooter I place the formulas
GF1a InitilizeGlobalV
GF1b GlobalV
GF1c DecrementGlobalV
GF1d GlobalV
GF1e DecrementGlobalV
GF1f GlobalV

What I want is in GF1b for GlobalV to return 6,
in GF1d it should be 5
in GF1f it should return 4

All my other calculations and formulas are written using GlobalV and can access the correct ranges of elements etc, and call functions with the values all based on GlobalV, but
in the example above GlobalV always returns 6.
Adding WhilePrintingRecords to all of the formulas has no effect.

How can I get to evalute the changes to GlobalV?

 
The problem is that each section of the group footer is still the SAME group footer, so the value of any variable is the same throughout. You can check this out also by adding the special field "groupnumber" to the footer--the value will be the same in each.

In fooling around with this, though, I discovered that if you save the decrement formula under a different name and place it in the section where you want the decreasing value, it will "decrement" (is that a word?). I also used "whileprintingrecords" in all formulas.

I'm not sure why this works--it seems that the first formula {@decr1} holds the value and then subsequent formulas decrease from there. In other words, if you copied {@decr1} into sections c and e, you would get the same value, 5 for each. However, if you copy the contents of {@decr1} exactly, and call it {@decr2} and place it in the e section, the values will be 5 for c and 4 for e.

Similarly, if you save the display value under a different formula name each time you display it, it will reflect the decreased value in the preceding section.

Of course, this method would be unnecessary if you were "decrementing" with these formulas across group instances instead of within one instance.

On an unrelated note, this method also allows for alternating colors within multiple sections of one report section, since it results in different values per section that can be used for conditional formatting--a problem that was outlined in an earlier thread, which I don't think was resolved at the time (although I might be wrong about that).

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top