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

Passing shared variables? 1

Status
Not open for further replies.

northw

MIS
Nov 12, 2010
140
US
Hi all,

I have question regarding shared variables, I have sub report in which, I have a query filter with certain codes, when I run the sub report, its showing all the records based on the query filter, but while declaring the value as shared variable and passing it to main report, It passes only the first code results to the main report.
Ex: If I have selected codes (1, 2, 3) and the related records to that codes are displayed in the sub report, when I run the sub report, But when I want to pass the values to the main report, I could see only the records of code(1), I have cross checked with different codes, and noticed it is passing only one values(First value).

any help is appreciated.
Thanks in advance.
 
A shared variable can only hold one value at a time.

If you want 3 values you will need 3 variables.

OR change the position of the subreport so that it executes 3 times and passes value on each execution.

Alternatively it could be that you are not resetting the value of the variable and its only holding the latest value.

Ian
 
You need to explain in what section the subreport is located and it what section you want to see the shared variable displayed. Also identify the group fields in the main report (what you are grouping on) and how you are linking the subreport to the main report--on what fields--if you are linking it.

-LB
 
Sorry for the Incomplete information.

Ian, I am passing six shared variables, each one is a database field. and I have my subreport in the report header.

LB, Subreport is in report header. And I am using the shared variables passed from the subreport for formating the data in the detail section of the main report, And the data in the main report is grouped into 4 groups, and I want to use these shared variables for highlighting purpose, which is hardcoded now, but I have to make it dynamic, So each corporate has different values to be highlighted, Due to the database design, I am forced to do this using shared variables from subreport, The main report and subreport is linked with corporation parameter.

Thanks
 
Formula using to highlight,

In subreport:
shared stringVar goal1:= if {Query1.Test Id} = 27 then {Query1.Test Goal1};

In Main report for highlighting:
shared stringVar goal1;
shared stringVar goal2;
if not (round({@var Avg abc},1) <= goal2 and round({@var Avg abc},1) >= Goal1) then
crBold
 
In the subreport, you should place a formula like this in your detail section:

{@goal1}:
if {Query1.Test Id} = 27 then
{Query1.Test Goal1}

In your subreport report footer, use this for your variable:

whileprintingrecords;
shared stringvar goal1 := maximum({@goal1});

Then move the subreport to a GH1a section of the main report. Then you can use your formula for bolding successfully.

To make the subreport not show, you should suppress all sections within the subreport, remove the border, format the subreport on the subreport tab to "suppress blank subreport" and then in the section expert of the main report->GH1a->check "suppress blank section." You cannot suppress the subreport object or hide or suppress the section containing the subreport, but if you follow the above steps, it will disappear, along with the section it is in, but the shared variables will still be passed.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top