Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing shared variable values from subreport to subreport 1

Status
Not open for further replies.

yehong

Programmer
Sep 22, 2003
291
US
I have two subreports.
I want to pass value from Sub1 to Sub2. I declared shared variable in a formula @Shared1 and assigned it a value, placed at the footer of Sub1. Then declared same shared variable in another formula @Shared2 on Sub2 which receives value from @Shared1. Now I want to use the @Shared2 into Sub2's selection formula, but the formula @Shared2 does not appear in the list. Is there anything I am doing wrong here?
 
You will not be able to share variables between subreports but you can share them between subreports and the main report.
THe reason you cannot use that value in the selection criteria for the other subreport is the evaluation time of the record selection formula.
Record selections are processed in pass1(whilereadingrecords) and subreports are processed in pass 2(whileprintingrecords)

 
So is there any other way to use a shared variable value in a subreport's record selection ?
 
The values passed to the subreport are handled via a parameter Crystal creates for that purpose. It could be that the selection criteria is passed from main to sub using the links tab when the subreport is created; or a parameter you create can be used to pass the value from the main to the cooresponding field in the sub. In any case you would pass the value to each subreport using the subreport links tab.
 
In my case I don't want to link the sub2 to main report via a parameter. I just want to run sub2 separately by selecting data based upon value given from shared variable from sub1.
So does that mean its Crystal's limitation?
 
You could use a shared variable from sub1 in sub2 to suppress the unwanted records (instead of selecting wanted records), as long as sub2 is in a lower section of the main report than sub1. Within sub2, use the section expert and add a formula referring to the shared variable (using whileprintingrecords) in the suppression formula area.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top