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

Joined: 09 Jul 2012
Location: United States
Online Status: Offline
Posts: 8
Quote Ricci Replybullet Topic: Variable Help
     Posted: 09 Jul 2012 at 5:14am
I am having trouble passing a variable from my sub report back into the main report.
 
Main Report is a Change Order
  * Group 1 = Project Number
  * Group 2 = Contract Number & Change Order Number
 
The Sub Report is a different Budget Breakdown of the Change Order amounts
  (1) I have tried using Running Totals to assign the variables. This works if I only want to view the variable but not when I need to use it for a calculations in the main report
     Sub Report
      WhilePrintingRecords;
      If GroupName ({Contracts_10_ttx.Budget~Group5}) = '01'
          Then CurrencyVar OriginalMain := {#Originals};
 
     Main Report
      WhilePrintingRecords;
      shared currencyvar OriginalMain;
      OriginalMain
 
  (2) I have tried calculating the variable on each record. This also works for viewing only but not when I need to use it in calculations in the main report
 
  (3) I have tried putting the sub report in Group 1 header, Group 2 header and Group 2 footer in a higher section than where I need to use the variables, none works for calculations
 
I don't know what else to try. Can anyone help?
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 10 Jul 2012 at 7:08am
I think you have to declare the variable again in the subreport - I don't see "shared currencyvar OriginalMain" in what you've posted.
 
-Dell
IP IP Logged
Ricci
Newbie
Newbie
Avatar

Joined: 09 Jul 2012
Location: United States
Online Status: Offline
Posts: 8
Quote Ricci Replybullet Posted: 10 Jul 2012 at 11:23am
I forgot to post that part. I have a seperate formula declaring all the shared variables in the sub report called DeclareOriginals:
 
  Shared currencyVar OriginalMain;
  Shared currencyVar OriginalSub01;
  Shared currencyVar OriginalSub02;
 
Any other suggestions?
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 10 Jul 2012 at 1:19pm
The shared variable has to be declared in the formula that it is being used in.
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