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!

Parameter value in main report is not passed to a parameter in the subreport

Status
Not open for further replies.

maas

Programmer
Sep 3, 2009
148
BH
Hello Team,

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:
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 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 in the above steps.

Kindly assist me in passing the value of the parameter from the main report to the subreport.
 
One more thing I forgot to mention is that I am using Crystal Report 2011 where it was not an issue in crystal Report XI
 
Check the Record Selection formula in the Sub Report. I suspect that when you linked the Sub Report it added the Record Selection formula as:

Code:
{engine.reportnumber}={[highlight #FCE94F]?Pm-[/highlight]ReportNumber}

Amend it to:
Code:
{engine.reportnumber}={?ReportNumber}

Once changed it should only prompt for 1 parameter.

Cheers
Pete
 
Thanks for the help

But the parameters are passed {engine.reportnumber}={?ReportNumber} correctly

I want to pass a database field called {engine.rptno} to the subreport from the main report. In the subreport, I create a

parameter with the name ReportNumber, it type is number and it is static. I matched the {?ReportNumber} = {engine.rptno} in

the sub report select Expert.



Then in the main report, I did right click on the sub-report and I clicked on “Change Sub report link”.



I selected the field {engine.rptno} from the main report and I linked it with the parameter in the subreport{?ReportNumber}.

When I ran the report, the application gives me an error that:


Cannot find parameter field ReportNumber 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)


Even I tried using "Change Sub Report Link" to match the {engine.rptno} from the main report and to link it with the field

in the sub report {engine.rptno} using the parameter {Pm-@ReportNumber}, it produces the above error.


So, how can I pass the value of the {engine.rptno} from the main report to the sub report?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top