Subreports and Variables

Hi Guys
I have been working on a report I like to call "subreport hell" at the moment.
Its a bit brutal and a little crude right now, but its almost doing exactly as designed

I am having trouble as I have a grid of subreports which are going away and extracting data for each historical year back to 2008 based on a value trn_cde.
The subreports all pass variables back to the main report for summing for each record.
Howver I am having trouble zeroing out the variables for the next record. Do subreports not run on a per record basis?
The first record is correct, but the subsequent records each have some values from the last record still being added up.

Can anybody offer advice. Its so close to be how I want it!

Screenshot shows all the subreports and the totals.
Its a bit ugly there are variables for each subreport passed back.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

What section is it in?

Subreports run everytime the section runs.

If you need to 0 shared variables the best place might be in the subreport report header.
You can also do it in a section before the subreport section but it has to be a section at the same level (group header, detail, etc)

StratfrordDCAuthor Commented:
The subreports are all split into their own details section

What is happening is that even if the subreports  for the 2008 year go away and get nothing ( no values in the database ) the last time there was a variable value, it simply carries through those variable numbers. Distorting my results horribly.

Each subreport line has its own details section. I have tried resetting the variables in details section a and all the subreports before they pick up a value.

They are shared variables, but this is for summing purposes.
StratfrordDCAuthor Commented:
I just realised
Its most crazy mistake.

Where I was setting the variable to zero I was saying varLevy=0; instead of varLevy:=0; I was giving a boolen TRUE where i wanted to zero a variable!

I just need to look at my report with a fresh pair of eyes
thanks for your help mimcc.

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
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
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.