Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: How to pass value between main report & subreport Post Reply Post New Topic
Author Message
hiuyil
Newbie
Newbie


Joined: 29 May 2011
Location: Hong Kong
Online Status: Offline
Posts: 6
Quote hiuyil Replybullet Topic: How to pass value between main report & subreport
     Posted: 29 May 2011 at 10:10pm
1st, I want to initiate a variable in main report like:
 
Shared numbervar CartonCount:=0;
 
Then, I wil pass the variable to sub-report and do the calaulation and pass back to main report (these actions will repeat several time because I put the sub-report in details part):
 
local stringvar a="";
Shared numbervar CartonCount;
 
if ( (CartonCount = 0) and count ({app_shipping_UnitLoadDetail.header_path}) > 1)
then (
a := "CARTON"+ Totext(CartonCount+1)
CartonCount := CartonCount + count ({app_shipping_UnitLoadDetail.header_path}) 
a := "-"+"CARTON"+count ({app_shipping_UnitLoadDetail.header_path})
}
 
However, there is an error message in the highlighted(in red colour) CartonCount indicated by cursor:
"The ) is missing"
 
Anyone can help me to fix it and tell me if it is correct or not for what I did.
 
What I want to do is that I want to hv an accumulated a result which proceed the calculation in sub-report and pass it back to main report. Then, the main report run the detail part, the variable will be passed from main report to sub-report again -> calculations -> pass back to main report. (these actions proceed several times)
 
 
Thanks * 10000
IP IP Logged
Stang67
Newbie
Newbie
Avatar

Joined: 14 Apr 2011
Online Status: Offline
Posts: 12
Quote Stang67 Replybullet Posted: 30 May 2011 at 2:27am
Hi hiuyil

one "wrong" thing, what i see is (bold marked):

if ( (CartonCount = 0) and count ({app_shipping_UnitLoadDetail.header_path}) > 1)
then (
a := "CARTON"+ Totext(CartonCount+1)
CartonCount := CartonCount + count ({app_shipping_UnitLoadDetail.header_path}) 
a := "-"+"CARTON"+count ({app_shipping_UnitLoadDetail.header_path})
}

I didn't find the open { or the close ), perhaps this is the "The ) is missing" Problem ;)

regards
Stang67
IP IP Logged
hiuyil
Newbie
Newbie


Joined: 29 May 2011
Location: Hong Kong
Online Status: Offline
Posts: 6
Quote hiuyil Replybullet Posted: 30 May 2011 at 8:11am
Thanks for your answer. However, The error message still occur : "The ) is missing" after I changed "}" to ")" at the end of the formula.
 
Still don't know what the problem isCry
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 31 May 2011 at 4:59am
when you check the formula it usually jumps to the location missing the value
 
if ( (CartonCount = 0) and count ({app_shipping_UnitLoadDetail.header_path}) > 1))
then (

a := "CARTON"+ Totext(CartonCount+1)
CartonCount := CartonCount + count ({app_shipping_UnitLoadDetail.header_path}) 
a := "-"+"CARTON"+count ({app_shipping_UnitLoadDetail.header_path}))

see the ( in red) i believe its the first 1 that is causing you grief. try removing it or adding one after >)


sharona
IP IP Logged
Stang67
Newbie
Newbie
Avatar

Joined: 14 Apr 2011
Online Status: Offline
Posts: 12
Quote Stang67 Replybullet Posted: 31 May 2011 at 5:00am
Hi Hiuyil,

please try this:

local stringvar a="";
Shared numbervar CartonCount;
 
if ( (CartonCount = 0) and count ({app_shipping_UnitLoadDetail.header_path}) > 1)
then (
a := "CARTON"+ Totext(CartonCount+1);
CartonCount := CartonCount + count ({app_shipping_UnitLoadDetail.header_path});
a := "-"+"CARTON"+Totext(count ({app_shipping_UnitLoadDetail.header_path}));
)

My changes are:
; at the end
Totext(count ({app_shipping_UnitLoadDetail.header_path})


in my report it works :D


Edited by Stang67 - 31 May 2011 at 5:01am
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