Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shared variable between two subreports 1

Status
Not open for further replies.

sangisiva

Programmer
Apr 7, 2008
44
IN
Hi,

I am working in a report which has 2 subreports.

I am trying to pass the shared variable between first subreport to second subreport.. But no luck :-(

Here goes what I have done
1. Created a forumla with shared array variable in the first subreport and filled up array variables and placed the formula in group header.

@Action Array Position
whileprintingrecords;
numbervar Act_counter1;
Act_counter1:=Act_counter1 + 1;

and

whileprintingrecords;
evaluateafter({@Action Array Position});
numbervar Act_counter1;
shared numbervar array Action_cnt_Array;
shared stringvar array Action_GrpName_Array;
Action_GrpName_Array[Act_counter1]:={@Grouping};
Action_cnt_Array[Act_counter1]:=distinctcount({Command.project id},{@LBUGrouping});

and

@Pending_Counter
Shared numbervar Pending_Counter;
Pending_Counter:=Pending_Counter+1;


2. Created a formula in the main report to declare the shared variable

whileprintingrecords;
shared numbervar array Action_cnt_Array;
shared stringvar array Action_GrpName_Array;
Shared numbervar Pending_Counter;

3. Created a formula for the second subreport shared variable and use the array to display it.

shared numbervar array Action_cnt_Array;
shared stringvar array Action_GrpName_Array;
Shared numbervar Pending_Counter;
shared stringvar Act_DispString1;
shared numbervar i;
For i :=1 to Pending_Counter do
if Action_GrpName_Array={@LBUGrouping} then
Act_DispString1 := Action_GrpName_Array;//Action_cnt_Array[j];
Act_DispString1;


What I am doing wrong here ?

Any help in appreciated.





 
From the help file"

In order to use shared variables, the variable must be declared and assigned a value before it can be passed between the main report and the subreport.
 
Hi MarsianStar,

Thanks for the response.

I tried assigning the array variable in the main report before passing to second subreport. But I get only last group's value.

LBUGrouping is a forumla by which I group the reports.

For eg, When I have 4 groups
Group name Count
AA 3
BB 1
CC 2
DD 34

I get only DD and 43... :-( Butin main report all the group names and its corresponding count respectively...

I could not figure out why it gives only last value...

 
If you are trying to address the issue in your crosstab post, then please see that post. I think you are overcomplicating this. You need to move the sub into the group header that reflects the field you are linking on.

-LB
 
Hi All,

I made it :)

I changed the scope of the counter variable of second subreport as shared.Now it works perfect.

Thanks to MarsianStar, I got a hint from your post.

Thanks to All.
Sangeetha Sivakumar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top