Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: shared Variable has me stumped!! Post Reply Post New Topic
Author Message
slstokes
Newbie
Newbie


Joined: 14 Jul 2009
Online Status: Offline
Posts: 4
Quote slstokes Replybullet Topic: shared Variable has me stumped!!
     Posted: 14 Jul 2009 at 12:24pm
Been bang my head with this one all day. I have used shared variables a whole bunch and never run into this problem. I'm sure it's something simple but I sure can't figure it out:

I have a subreport totaling some inventory  data. I have created a shared variable in the sub and main reports to display the data because I need to use the shared variable value in a formula in the main report.

The shared variable in the sub shows the expected value. The matching shared variable in the main report shows the value for the record prior to it. The first record shows zero when the sub has a value for it.

The shared variable and sub report are in GF2 which is the inventory item summary in my report.

If anyone has any suggestions on things for me to look at, I'd sure appreciate it. Bellow are the formulas for the shared variable.

Many thanks,

Stokes

sub def:
whileprintingrecords;
shared numberVar sharedMatlUsage;
sharedMatlUsage := Sum ({MatlUsageTran.Quantity-Purchase})

main def:
whileprintingrecords;
shared numberVar sharedMatlUsage;
sharedMatlUsage
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 14 Jul 2009 at 6:48pm
I don't use them that much but since you are using the shared variable in the main report to display the variable from the subreport shouldn't that be put onto section GF2B in order to display the data from GF2?

Edited by DBlank - 14 Jul 2009 at 6:49pm
IP IP Logged
slstokes
Newbie
Newbie


Joined: 14 Jul 2009
Online Status: Offline
Posts: 4
Quote slstokes Replybullet Posted: 15 Jul 2009 at 5:22am
Thank you for getting me to look at that again (and a fresh start this morning!). I had tried every combination of placement of the subreport and shared variable using subsections with no result. BUT, I had formulas using the shared variable in GF2a and when I moved them along with the shared variable to GF2b, the shared variable displayed the correct value. Silly me!

It's still not clear to me why the shared variable was displaying the next record value but I'm glad the report is correct now. Thanks again!
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