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

Subreport parameters - same as main report 1

Status
Not open for further replies.

c15bm

Programmer
May 29, 2003
10
CA
I have a main report calling 3-4 subreports. The subreports share the same parameters. Is there any way to pass the parameters from the main report, without having to re-define them in the subreport.

The reason for this is that I have to plug in the report to a Fuels Management system and I don't think I'll be able to do that as the report is written today.

 
Which Crystal? In 8.5, [Subreport Links] is found under [Edit] on the menu. You should be able to make a link - create a dummy formula field in the subreport if necessary.

One point to watch out for. Crystal will generate a command in the Subreport's Section Formula, whenever a link is made. Check and get rid of it, if this is not what you want.

Madawc Williams
East Anglia, Great Britain
 
Right click the subreport and select Change Subreport Links.

Select the parameter from the Container report fields list, and select the field from the list below to link to.

Madawc mwas making a reference to the Report->Edit Selection Formula->Record wherein the link will be defined. You can edit it if required, such as in the case of using 2 date parameters against 1 field.

-k
 
There's no reason you cannot share parameters. Many people make the mistake of creating the parameters again in the subreports - this leads to confusion!

The parameters should only be defined in the main report.

Using the subreport links tab you can select the parameters from the main report and they will be passed to the subreport (crystal will create new parameters in the subreport automatically prefixed with '?Pm-').

As Madawc points out - the subreport links tab will only allow you to link the parameters to fields in the subreport of the same data type as the parameter. This may cause confusion if there are no fields in the subreport of this type (e.g. passing in a date parameter when only date/time fields exist).

In these cases, create a formula field in the subreport of the type needed

e.g. @test_date
date(2004,01,01)

Then retry linking the date parameter to the subreport's @test_date formula.

The last step, again as Madawc points out, is to check the select expert in the subreport. It defaults to

@test_date = ?Pm-?passed_in_parameter

You can now change this to whatever you intended to do with the passed-in parameter. In fact, on some occasions, you might not want to use the parameter in the selection at all.

Hope this helps

Steve Phillips, Crystal Trainer/Consultant
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top