I have two reports set up the same way one works yet the other does not. I initialize the variables in the first group
shared StringVar Array WcAr := [""];
shared StringVar Array ShAr := [""];
shared StringVar Shstr :="";
shared StringVar Array RhAr := [""];
shared StringVar Array UcAr := [""];
shared StringVar Array TcAr := [""];
shared StringVar Array BuAr := [""];
shared StringVar Array RqAr := [""];
shared StringVar Array SqAr := [""];
shared StringVar Array BcAr := [""];
shared NumberVar x := 1;
I then load the array in Group 4(Work Center)
shared StringVar Array WcAr;
shared StringVar Array ShAr;
shared StringVar Shstr :="";
shared StringVar Array RhAr;
shared StringVar Array UcAr;
shared StringVar Array TcAr;
shared StringVar Array BuAr;
shared StringVar Array RqAr;
shared StringVar Array SqAr;
shared StringVar Array BcAr;
shared NumberVar x;
(if not IsNull({@Work Center}) then WcAr [x] := {@Work Center};
ReDim preserve WcAr[UBound (WcAr)+1];
ShAr [x] := Cstr({Job_Operation.Act_Setup_Hrs},"####.##",2,",",".");
ReDim preserve ShAr[UBound (ShAr)+1];
RhAr [x] := Cstr({Job_Operation.Act_Run_Hrs},"####.##",2,",",".");
ReDim preserve RhAr[UBound (RhAr)+1];
UcAr [x] := Cstr({Job_Operation.Act_Unit_Cost},"####.##",2,",",".");
ReDim preserve UcAr[UBound (UcAr)+1];
TcAr [x] := Cstr({Job_Operation.Act_Total_Cost}+
{Job_Operation.Act_Run_Labor},"####.##",2,",",".");
ReDim preserve TcAr[UBound (TcAr)+1];
x := x+1;);
I output these in the group footer using for each array
shared StringVar Array WcAr;
Join(WcAr,ChrW(10));
Only the first item is added to any of the arrays. x has incremented and is equal to 17 which indicates it going through the formula. I have tried without the if statement and anything else I can think of but I always get the same result.
That should work, at least for your
WcAr. As you're using Chr(10) as divider for the array elements, I guess you just see only the first element because the field formatting does not allow it to increase. => Either activate "Can grow" in output field format, or use another divider.My test scenario is these three formulae, where COMMAND.STRING is the input field of course:
init
add
output
Important: The add formula field must be placed in a repeated section, in my case it's the detail section, inyour case probably a group header. The output formula can only show the collected values when it's placed in a section after the one where the last value is collected (or in it).