I would suggest keeping the total inside the sub-report, using the Total option in QueryFormat (see the help). Otherwise it will be hard to get the total “out” of the sub-report.
Another option is to just do a separate QueryTotal to get the total. (Somewhat redundant, but simple.)
One thing to remember is that reports run somewhat “asynchronously”. They don’t necessarily execute in the order that you might expect, making it difficult (or impossible) to pass variables around.