Crystal Reports 2008 unable to link parameters to subreport

crystal-reports-2008

In Crystal Reports 2008 I have a main report with arg_beg_date and arg_end_date parameters. I want to pass these to a subreport, but have not been able to. The subreport has a Command with a SQL query in it – SELECT * FROM TXFR to keep it simple. I created two parameters in the subreport named beg_date and end_date, then adding WHERE TXFR_DATE BETWEEN {?BEG_DATE} AND {?END_DATE} to the query. I tried to Change Subreport Links, find arg_beg_date in the Available Fields, and clicked ">" to move it to the Field(s) to link to box.

At that point I only see ?Pm-?arg_beg_date and "Parameter Fields" as choices in the "Subreport parameter field to use" box. I cannot link arg_beg_date from the main report to the beg_date parameter I created in the subreport.

I saw in another question where someone suggested checking the box for "Select date for subreport based on field" and selecting "report fields", but I am unable to do that. It just highlights and selects a field below that in the box.

Any ideas?

Best Answer

I've recently built the same report where the Subreport is a command line. I haven't written up a procedure yet but this is how the parameter should look like if you are passing a parameter from the main report to the sub report.

In your subreport SQL, the parameter must be this

WHERE TXFR_DATE BETWEEN {?Pm-?arg_beg_date} AND {?Pm-?arg_end_date}

Then in your parameter list, create

  • Pm-?arg_beg_date
  • Pm-?arg_end_date

In your main report, Change Subreport links...

  1. Add the ?arg_beg_date parameter
  2. Make sure the "Select data in subreport based on field" is unchecked
  3. Do the same for ?arg_end_date parameter

In case you want to pass a field instead of a parameter and you are using a command in your main report, same steps as above but looks like this.

Subreport SQL

{?Pm-Command.FieldName}

Parameter List

Pm-Command.FieldName

Related Topic