Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Shared Variable Post Reply Post New Topic
Author Message
apuente
Newbie
Newbie
Avatar

Joined: 26 Nov 2012
Online Status: Offline
Posts: 15
Quote apuente Replybullet Topic: Shared Variable
     Posted: 04 Mar 2013 at 1:11pm
Hi, I have a Main report with invoiced order data and i have a sub report that contains the job cost for those sales orders. Not all of the Invoiced sales orders have Jobs, so they will not have a record on the Jon subreport.
 
What i want is to display the Cost from the subreport on the main report.
i have created a variable in the subreport
 
 shared numbervar labor := Sum ({V_JOB_HEADER.AMT_LABOR},{V_JOB_HEADER.SALES_ORDER} )
 
when I declare it in the main report and try using it in the group footer it gives me the data from the previous Sales order
 
can anyone help?
Thank You,
Antonio
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 05 Mar 2013 at 6:11am
You need to create a new formula to reset the value of the variable and place it in the group header:
 
shared numbervar labor := 0;
 
By putting the semi-colon at the end, the value won't appear but the formula will evaluate and reset the number to 0 at the start of every group.  This way it will be 0 if the subreport doesn't have any data.
 
-Dell
IP IP Logged
apuente
Newbie
Newbie
Avatar

Joined: 26 Nov 2012
Online Status: Offline
Posts: 15
Quote apuente Replybullet Posted: 06 Mar 2013 at 10:24am
Thank you very Much, that worked great!! Now I am trying to get the total sum of these labor costs but i cant simply summarize that field.
Is there a way to do this using a variable that will give me the total labor costs from the subreport that are applicable on the main report?
 
 
Thank You,
Antonio
IP IP Logged
guptaa
Newbie
Newbie


Joined: 21 Feb 2013
Location: United States
Online Status: Offline
Posts: 14
Quote guptaa Replybullet Posted: 14 Mar 2013 at 10:58am
I have been struggling to bring the correct value via shared variable in my main report and would appreciate some help.

The main report has no data but one sub report.

The sub report has 3 groups: county, supervisor, Part
Part is the 3rd group.
Part has value of 1,2 and 3.

I need to pass the part.value to the main report's page footer (since sub report has no page footer.)
There is a different page footer for each part.

I created a formula and placed in on detail section of subreport:

WhilePrintingRecords;
shared numbervar v_footer;
v_footer := {SP_CF17_CPS_UNIT.PART}

I created another formula and placed on Group4_Footer section

WhilePrintingRecords;
shared numbervar v_footer;

When I display the sub report itself, there is correct value displaying in its footer section but when placed in main report, not getting correct part value in main report - page footer.

Placed sub report in main report's Report_Footer section (also tried in detail section since the value is needed to the page footer).
A formula placed on page footer-A section:
WhilePrintingRecords;
shared numbervar v_footer;

I am resetting value to zero of this variable in page_header section (tried in report header section also):
shared numbervar v_footer := 0;

problem is: getting value 0 when needs to be 1, getting 1 where needs to be 2....

Any help would be greatly appreciated.
I probably didn't do good job explaining...please ask for any clarification..
thanks for any help.






Edited by guptaa - 14 Mar 2013 at 2:40pm
Aradhana
IP IP Logged
apuente
Newbie
Newbie
Avatar

Joined: 26 Nov 2012
Online Status: Offline
Posts: 15
Quote apuente Replybullet Posted: 14 Mar 2013 at 12:50pm
Hi Gupta,
 
your comment was left blank
Thank You,
Antonio
IP IP Logged
guptaa
Newbie
Newbie


Joined: 21 Feb 2013
Location: United States
Online Status: Offline
Posts: 14
Quote guptaa Replybullet Posted: 14 Mar 2013 at 2:43pm
my apologies...newbie here.
Please find my question posted.
Your help would be greatly appreciated.

thanks
Aradhana
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum