The method you've described should work fine, depending upon WHERE in the main report you have your formula, and where you have the subreport.
The formula setting the shared vcariable must be placed in a section PRIOR to the subreport running.
Why don't you state the purpose of this? I'm guessing that there's a language barrier, but in any case, you should post WHAT you are trying to do, otherwise often times people come back and say I'm a newbie and was guessing at how I might accomplish something but my guess doesn't work, why don't I take the time to truly convey requirements now...
It only takes a few moments to state the basics:
Crystal version
database/connectivity used
Example data
Expected output
-k