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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.