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


Joined: 25 Aug 2009
Location: United States
Online Status: Offline
Posts: 37
Quote pgiering Replybullet Topic: Shared Variable
     Posted: 30 Sep 2010 at 7:49am
CryHi, I've used shared variables sucessfully in the past, but I'm having trouble with one and I'm not sure why.
 
I'm working with a Trial Balance report, that simply returns a Year To Date balance for each account.
 
I need to convert that report to return only activity from a certain point in time.
 
Essentially, the report should continue to return the YTD balance, but then subtract the balance as of June 30.  So, if the balance at June 30 was "3", and the balance at the end of August was "7", the report would yield "4". 
 
In the subreport, which is just a list of accounts in the first column and balances in a 2nd column, I have the followong variable assigning the shared variable:
 

     Shared NumberVar Jun2010EndBal;  

     Jun2010EndBal := ToNumber(({@Balance at Date})

As a test to see if it is working, I drop this in as a third column in the report, and it displays the balance (so I think it is working).
 
In the main report, I'm using the following variable to place the value in the report:
 

     Shared NumberVar Jun2010EndBal; 

     Jun2010EndBal

As a test here, I am also placing the variable as a third column in teh report, but it just shows zero for every account. 
 
Any suggestions?
 
Thanks,
 
PaulCry


Edited by pgiering - 30 Sep 2010 at 8:13am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 30 Sep 2010 at 9:15am

1. are you suppressing the sub-report? If so by what means?

2. Is the variable in the main report being placed in a  section below the subreport that it is reading from?
IP IP Logged
pgiering
Newbie
Newbie


Joined: 25 Aug 2009
Location: United States
Online Status: Offline
Posts: 37
Quote pgiering Replybullet Posted: 30 Sep 2010 at 9:59am

DBlank,

I am suppressing the sub-report.  I have it inserted in the main report section "Detail b".  I right-clicked that report section and selected "Suppress (No Drill-Down)".
 
For the test, I simply placed the variable along side the regular (non-subreport) data (which is just a list of account numbers).  
 
I suspect that part of my problem is that within the subreport, the variable data is associated with the account numbers, but when I import it into the main report, even though the accounts are all the same, I'm not sure that there is any way to maintain the association with thos numbers.
 
If that is a problem as I suspect, is there a way to bring the variable over in a way that it will maintain the association?
 
Thanks
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 30 Sep 2010 at 10:04am

I am pretty sure that if you suppress a sub report it does not run and therefoer there is no shared field to be returned.

instead, suppress all of the fields in the subreport and then if need be you can mark the section in the main report that it resides on as 'suppress if blank'
 
All that being said I don't know why you don't just use a Running total to get your new values. Much more efficient than sub reports.
IP IP Logged
pgiering
Newbie
Newbie


Joined: 25 Aug 2009
Location: United States
Online Status: Offline
Posts: 37
Quote pgiering Replybullet Posted: 30 Sep 2010 at 10:06am
Hmm.  I hadn't thought of the running total.
 
I'll try changing the suppression, and if that doesn't work, I'll try the running total.
 
Thanks!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 30 Sep 2010 at 10:09am
RT is way easier Smile
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