Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Subreport is not getting parameter from mainreport Post Reply Post New Topic
Author Message
maas
Newbie
Newbie


Joined: 26 May 2009
Location: Bahrain
Online Status: Offline
Posts: 15
Quote maas Replybullet Topic: Subreport is not getting parameter from mainreport
     Posted: 28 Apr 2014 at 7:53am
I need your assistant in passing a value of a parameter in the main report to the subreport. I defined a parameter in the main report which is called {?ReportNumber} and its type is Number and it is static.

In the Select Expert of the Main Report I added the below code:

{engine.reportnumber}={?ReportNumber}

This will take the value of the reportnumber from the table and it will assign it to the parameter. Each time I ran the report, the value will be different based on the retrieved data.

In the Subreport, I created again a parameter with the same name {?ReportNumber} and its type is Number and it is static.

I have also did in the Select Expert of the subreport I added the below code:

{engine.reportnumber}={?ReportNumber}

I have added a subreport link which is {?ReportNumber} parameter and below I selected to match the {?ReportNumber} parameter which is in the subreport.


However my issue is that when I ran the report, the report is prompting me to enter the parameter of the subreport, even though I have added and assigned a value to it as I have explained it in the above steps.

I am using Crystal Reports 2011

Kindly assist me in passing the value of the parameter from the main report to the subreport.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 28 Apr 2014 at 8:14am
{engine.reportnumber}={?ReportNumber}
note this does not assign  any value to anything but rather it compares two values to each other and if the comparison is TRUE then it includes the record in the report.
If your main report param is set to only allow a singl value you do not need to create the param in the sub report.
Simply use the link option selecting the param from the main report to point o the engine.reportnumber field in the sub report.
IP IP Logged
maas
Newbie
Newbie


Joined: 26 May 2009
Location: Bahrain
Online Status: Offline
Posts: 15
Quote maas Replybullet Posted: 28 Apr 2014 at 11:26am
I tried to match the {?ReportNumber} from the main report using {?pm-ReportNumber} with the field rptno in the subreport, but unfortunately the application produced an error that I can't use the {?pm-ReportNumber}. Is there any work around for this?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 28 Apr 2014 at 11:48am
since there is only one possible reult you can just link the main report engine.reportnumber to the sub report engine.reportnumber.
 
Or
You can also, in the main report, create a formual field called whatever you want (e.g. @MRerportnumber) as
{?ReportNumber}
 
and use that formula field as the field to link from in the main report
 
IP IP Logged
maas
Newbie
Newbie


Joined: 26 May 2009
Location: Bahrain
Online Status: Offline
Posts: 15
Quote maas Replybullet Posted: 28 Apr 2014 at 10:40pm
Thanks for the help but the problem is still there.

I created a parameter in the main report with the name ReportNumber, it type is number and it is static.

In select Expert I defined:
{Engine.RPTNO} = {?ReportNumber}

Then, in the subreport, I create a parameter with the name ReportNumber, it type is number and it is static.

In the main report right click on sub-report and I clicked on “Change Sub report link”

Then, I selected a {?ReportNumber}from main report which and I linked it with the parameter in the subreport{?ReportNumber}.

When I ran the report, it prompts me for the parameter which is in the main report.



IP IP Logged
maas
Newbie
Newbie


Joined: 26 May 2009
Location: Bahrain
Online Status: Offline
Posts: 15
Quote maas Replybullet Posted: 28 Apr 2014 at 10:52pm
Originally posted by DBlank

since there is only one possible reult you can just link the main report engine.reportnumber to the sub report engine.reportnumber.

 

Or

You can also, in the main report, create a formual field called whatever you want (e.g. @MRerportnumber) as

{?ReportNumber}

 

and use that formula field as the field to link from in the main report

 


I tried to link the two fields which are in the main report and in the subreport without any parameters using "Change Sub Report Links". However, the system produces an error in the log file that is :

Cannot find parameter field Pm-Engine.RPTNO in subreport Engine-Stmnt.rpt

Also, I kept the {engine.rptno} in a formula and I try to link it with the field in the subreport, but it is the same, it produces that error:
Cannot find parameter field Pm-@RPTNO in subreport Engine-Stmnt.rpt

And below it this error:

In: XYZSystems.Client.Crystal.ReportHandler.PrintReport (Line 0)
   at CrystalDecisions.ReportAppServer.Controllers.ParameterFieldControllerClass.SetCurrentValues(String ReportName, String ParameterFieldName, Values Values)
   at CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition.ApplyCurrentValues(ParameterValues currentValues)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetParameterValue(String name, Object val)
   at XYZSystems.Client.Crystal.ReportUI.DisplayReport()
   at XYZSystems.Client.Crystal.ReportHandler.PrintReport(String rptfilepath, eXCRTo outputTo, Boolean doFooters, String sequenceNumber, String userName, Object oCtx, Object ActiveDataTables, String& reportTime, Int32 viewerWindow, Int32 reportNumber, Object propertyBag, Boolean resourceSecurity, String programName)

I need your kind assistance

Edited by maas - 28 Apr 2014 at 10:55pm
IP IP Logged
maas
Newbie
Newbie


Joined: 26 May 2009
Location: Bahrain
Online Status: Offline
Posts: 15
Quote maas Replybullet Posted: 29 Apr 2014 at 2:56am
Even tried to use shared variable in the main report:


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:

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 : the formula cannot be used because it must be evaluated later

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