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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shared variable values for grouped data 1

Status
Not open for further replies.

northw

MIS
Nov 12, 2010
140
US
Hi all,
I have an issue regarding shared variables.
We have a main report, with startdate, enddate and employer.
I was asked to add total number of users working with that employer, as we have startdate and enddate parameters, I have inserted a subreport to caliculate the total number of users per employer. I am passing the value through a shared variable, When the user selects just one employer it works fine, But when more than one employer is selected (like if user enters ALL) then the displayed shared variable in the main report shows just one value for all the employers, Is there a way to make the shared variable to display the number of users based on group?
I am using Crystal ver 10.
I have two groups one on employer and other on user.
and I am placing the shared variable in group footer 1.

shared variable formula in subreport:
whileprintingrecords;
shared numbervar x;
x:= {@test};
x

{@test}:
distinctcount({user}, ({emp.name}))

Mainreport formula:
whileprintingrecords;
shared numbervar x;
x

Thanks in advance!

 
alladi333,

I would think you are always getting the value from the last group in the subreport?

change your Subrpt formula to:
Code:
whileprintingrecords;
shared numbervar x;
x:= x+{@test};
x;

You were not adding x to the value stored in {@test}, so at the end of each group in the subrpt, itwas overwriting the value from the previous group (I would assume).

Hope this helps! Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Hi Thanks for the reply Mike.
When I drag this field in subreport group footer design, I could see the values for the all the selected employers separately. Any how I will try your suggestion and see.

Thank you!
 
It sounds like you didn't link the subreport to the main report on the group field. Go into edit->subreport link and add a link on the employer field. Once you do that the shared variable will be limited to the employer group. The sub must be in a section above the one where you are referencing the shared variable, e.g., if the sub could be in a group header section or in a group footer_a section with the reference to the variable in group footer_b.

-LB
 
Hi Lbass,
Thanks for the reply.
I have linked the main report with subreport using the parameter field on emp.name
and I have placed the subreport in report header.
Is there anything to do with resetting the value, because, I only get one value for all the emp.name group (the last value from the subreport).

Thanks.
 
The subreport has to be in the GROUP header for the emp.name group.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top