I had a real mystery yesterday that cost me a fruitless half hour. I was trying to pass a shared variable from a subreport in Report Footer B to a formula in Report Footer C. I could see the value being stored correctly in the subreport, but the formula in RFC would not update no matter what I did. So I did some testing.
I had another subreport in the Report Header and it also had some shared variables. I could display those in RFC with no problem. So I knew that at least some shared variables were working correctly. Also, if I moved the original subreport to the RH, the variables started working. So I knew that the formula syntax was right. It just would not work when the subreport was in the section where it needed to be, in RFB.
I even tried renaming the variable to something unique to make sure there wasn’t another formula using that variable name and interfering with my formula. The behavior didn’t change. As a temporary measure I put a second copy of the problem subreport into the report header. It redundant but everything worked just fine.
It was the customer that noticed some extra numbers in Report Footer A (the section above the subreport). What I found was a second copy of the display formula. That meant that there were two copies of the same formula sitting in different parts of the the Report Footer. One was in the section above the subreport and the other was in the section below the subreport. Deleting the formula above the subreport solved the problem.
This highlights a little know rule concerning formulas with variables. They will only fire once per section, even if the section is divided into multiple subsections. So the first instance of the formula gave the variable its value before the subreport had a chance to run. The second instance of the same formula already had a value for the Report Footer, and so it would not fire again to update that value, even though a subreport occurred between the two formula instances.
So I was on the right track when I tried changing the name of the variable. But since there was another instance of the same formula the variable was being changed in both instances. What I needed to do was change the name of the variable and create a new formula. That would have shown me the cause of the problem.
(For examples of my most popular formulas, please visit the FORMULAS page on my website.)