Print Page | Close Window

StoreVar and FetchVar Functions in CR 2008

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=17725
Printed Date: 06 May 2024 at 4:00am


Topic: StoreVar and FetchVar Functions in CR 2008
Posted By: Yosteevo777
Subject: StoreVar and FetchVar Functions in CR 2008
Date Posted: 10 Oct 2012 at 2:22pm

I am using Crystal Reports 2008.

I need to assign the calculated value of a formula to a Shared Variable that is configured within a subreport that is configured in a main report.

I then want to have the ability to recall the value of my formula calculation contained in my subreport in order to use that variable's value in other formulas in my main report.

(Similar to StoreVar and FetchVar Functions from earlier versions of Crystal Reports)

 


I have succeeded in creating a formula that assigns a value to a Variable within my subreport with the following syntax:

 

Shared NumberVar Ring1_AV_Store_Calculation;

Ring1_AV_Store_Calculation := {@AV Calculation for Both S1_S2}

 

 


Now I need help with the syntax and the process that fetches the value into the main report.
I have come across StoreVar and FetchVar Function tutorials online but they no longer work in Crystal Reports 2008.


Thanks
Stephen



-------------
Stephen Waichulis
LIMS Database Administrator



Replies:
Posted By: Sastry
Date Posted: 11 Oct 2012 at 2:30am
Hi
 
In crystal Shared variables will store the values and also fetch the values, these variables are global variables and can be used in your main report formulas.
 
Sample formula to store value  (in your case sub report value )
 
Whileprintingrecords;  // This formula store value to a 'xx' shared variable.
Shared Numbervar xx;
xx:={@AV Calculation for Both S1_S2};
 
 
In your main report to fetch the value, use the below formula :
 
Whileprintingrecords; 
Shared Numbervar xx;
 
This will display your sub report value in main repor.  Make sure that your sub report should get processed before you display the variable value.


-------------
Thanks,
Sastry


Posted By: Yosteevo777
Date Posted: 11 Oct 2012 at 1:29pm
Thanks Sastry,

After correcting my syntax, I also needed to import another copy of my subreport in my main report's header and suppress all the sections within the subreport copy.

I figured out that the subreport has to be at a higher level in the main report for the shared variables to calculate and become available in all lower sections of the main report.

Thanks
Stephen

-------------
Stephen Waichulis
LIMS Database Administrator



Print Page | Close Window