DavidZ;8734 wrote:
Could I not have two shared variables that are set the value of the subreports and then a third formula that puts the other two together in a good format?
If this is possible are you able to elaborate on the details of the shared variables (how I define them and where, and where to place the subreports etc)
You can actually do this with only one shared variable. You will need three formulas, though. You will need at least three sections: sub-report 1 goes in the first section; sub-report 2 goes in the second section; and the final formula goes in the third section. Sections are evaluated from top to bottom (with appropriate loops for various groups). Putting the sub-reports and the final formula in separate sections forces the correct order of evaluation.
4I don't know what method Crystal uses to determine the order of evaluation within a section. When the formulas are at the same level, you can use the
EvaluateAfter to force a particular order, but you can't do this when one formula is in a sub-report and the other is either in the main report or in a second sub-report. Because you can't force a particular order within a section, you need to put them in separate sections.
The actual code is very simple. As with many programming languages, you can declare a variable and assign a value in the same statement. For sub-report one, you simply assign the appropriate value to the shared variable. Make sure that the value has enough spaces at the end to separate the first result from the second. When sub-report 1 is blank, you want to return a zero length string ("").
Shared StringVar DavidsVar := <non-null string value for sub-report 1>;
In the second sub-report, you concatenate the existing value from sub-report 1 to that in sub-report 2.
Shared StringVar DavidsVar := DavidsVar + <non-null value for sub-report2>;
Finally, in the main report you display the value. You can't have a formula that only declares a variable, but you also don't want to change the variable. A semi-colon is required to separate statements within a formula.
Shared StringVar DavidsVar;
DavidsVar
If you want to have a particular separator such as "; " when both values exist, but none when either one is blank, then you can use an array variable. In this case, it is okay to return a null value, because you can account for that in the last formula.
Shared StringVar Array DV;
DV[1] := <SR1 value>;
Shared StringVar Array DV;
DV[2] := <SR2 value>;
Shared StringVar Array DV;
f1(DV[1]) + f2(DV[1],DV[2]) + f3(DV[2]);
Where f1() and f3() are functions that handle displaying that value including what do when it is Null and f2() is a function that determines what and when to display as a separator.
Drew