Subreport variable printing wrong in main report

I have a subreport which calculates a value. I set up the shared variable there and then use that to append values onto a total. The subreport is placed in a group header. I then create a formula in the main report to view that shared variable and place it in the same group section but just after the subreport yet it prints the value on the next group header. Does anyone know where I may be going wrong here?
Who is Participating?
bdreed35Connect With a Mentor Commented:
Divide the the group header section into 2 sections.
Right click the group header name in the left margin of the report and choose Insert Section Below.
Move your formula that references the shared vairable into the lower section (group header section b) and leave the subreprt in the a section.
Your formula should be correct now.
Brian is correct.  The reason for that is because you cannot reliably determine the order fields will be evaluated within a section.  Usually it works top to bottom but you can't depend on it.

Section A will always be processed/evaluated before Section B so by splitting it you insure they're evaluated in the correct order.

TerraKeithAuthor Commented:
The only problem with that is that I need to know the value of the variable returned so I can suppress the group section header and if so it's details section as well.
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Does your subreport only calculate the variable to determine if you should suppress or not?

The subreport has to run in order to calcualte the shared variable, so you can't suppress the section that contains the subreport.
You can suppress group header a, the details, and group footer based upon the shared variable.

If you subreport only present to calculate the value, then suppress all the sections in the subreport except one of the report footers.
In the main report, make the subreport and the group header a section hieght as small as you can.  Also, right click the subreport, choose format, and under the comnon tab, make sure the can grow proprty is not set.

Does this help at all?

There are some more complicated alternatives that can be explored if need be.
TerraKeithAuthor Commented:
Thanks for the help
TerraKeithAuthor Commented:
It worked a charm
All Courses

From novice to tech pro — start learning today.