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

Failure in passing shared variable in main report to subreport select expert

Status
Not open for further replies.

maas

Programmer
Sep 3, 2009
148
BH
Hello team,

I need your assistant in passing a database field called {engine.rptno} to the subreport select expert from the main report. I tried to use shared variable in the main report.

I created a formula in the main report

Code:
shared numbervar report_number := {engine.rptno};

report_number;

In the sub report, I create a formula ("Shared_report_number") and I placed it in the report header. It has the code:

Code:
shared numbervar report_number;

report_number;

I clicked on Select Expert and then I chose the field {engine.rptno} is equal to {@Shared_report_number}, it produces and

error that : crystal reports the formula cannot be used because it must be evaluated later
Can you please help me in this.
 
If you're using this in the Select Expert in the subreport, the easiest way to do this is to set up a subreport link on that field. This will automatically create a parameter in the subreport and a line in the Select Expert in the subreport. You only need to use a shared variable if you're going to change the value of it in the subreport.

-Dell

DecisionFirst Technologies - Seven-time SAP BusinessObjects Solution Partner of the Year
 
Hi Hilfy

I am working on a 3rd party application and the application is producing errors if I used any parameters
 
I don't know if this will work, but it's worth a shot:

1. Place the formula in the main report in an appropriate section at some point before the subreport. This will guarantee that it gets evaluated and that the variable has a number. Because of the final semi-colon (";") it shouldn't actually display anything.

2. Change the subreport formula to this:

BeforeReadingRecords;
shared numbervar report_number

Note that there is no final semi-colon.

-Dell

DecisionFirst Technologies - Seven-time SAP BusinessObjects Solution Partner of the Year
 
Thanks for the post hilfy

I will try your solution and I will revert back.

One more thing when I am passing the report number as parameter @ReportNumber from the main report to the subreport using the Change Subreport link by selecting only the {?ReportNumber} parameter which i created in the subreport: I got the below error:

Cannot find parameter field ReportNumber in subreport
 
You can use parameters to filter data or to just pass a value to an existing parameter - to pass in a parameter that is not going to be used to filter data, make sure that you turn off "Select data in report based on field" in the bottom-right of the linking screen. Then you match it up to the parameter in the drop-down on the bottom-left of the screen to pass the value to that parameter.

-Dell

DecisionFirst Technologies - Seven-time SAP BusinessObjects Solution Partner of the Year
 
What I am trying to do is that I want to pass the report number field which is taken from the database {engine.rptno} to the subreport and to make sure that the subreport doesn't use any other report number. The subreport is having also the field {engine.rptno} and the same tables except that my concern is that it shouldn't take any other report number.

So what do you suggest in which way should I pass the {engine.rptno} and to make the subreport take this report no?
 
The way I would do this would be to select the data based on the field. This will automatically create a parameter in the subreport (the name will start with "pm_") and it will automatically set up the filter in the Select Expert (DO NOT manually create the parameter in the subreport!). It won't prompt you for the parameter because it will be set by the link. See if that will work in your software. If it doesn't, then you'll need to use the shared variable - if you do this, DO NOT set up a subreport link.

-Dell

DecisionFirst Technologies - Seven-time SAP BusinessObjects Solution Partner of the Year
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top