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!

Passing parameters to sub report

Status
Not open for further replies.

Cyked

MIS
Jan 15, 2010
29
US
I have a report where I am using 3 sets of parameters for begin and end dates (report, current, previous). The main report uses report_begin_date and report_end_date in the select statement to grab 2 months worth of data. In the main report where I am displaying monthly data metrics I use formulas and running totals using current being/end dates and previous begin/end dates to show either current month data or previous month data.... Hope that makes sense...

Anywho, I have multiple sub reports in the main report using the SAME parameter field names, and I want to link them so I have only prompted for 3 sets of parameter field entries (report, current, and previous). When I insert one of the sub reports I am prompted for more than 3 sets of parameter field entries when refreshing the report if I want to change a date range somewhere (ranges are duplicated). I tried using the subreport links to link main report param fields to the param fields in the sub report, but that didn't change anything.

Is this not the point of linking the main report fields to the sub-report fields? Or does it not work this way specifically because I am using date type parameter fields?

Thanks!
 

In the linking dialog, the dropdown where you specify the subreport parameter will have two entries for each parameter.

For instance:

?BeginDate
?PM-BeginDate

The ones prefaced with PM are created automatically, and if you use them you will get prompted multiple times for the same parameter.

I would bet that this is what is happening for you - change the links to the non-PM parameters and see what happens.

 
Thanks Brian. This is what I was doing. I have it working now. I created a new report to test with pretty much nothing in it (i.e. parameters, formulas, etc.)

As an aside to this, either this is me and I'm crazy or its crystal screwing with me. Is there a way to PURGE everything in a report? In field explorer there are green check marks next to items in use/on the report canvas. From what I have seen, again I might be crazy here, but it seems that even if I remove something from the report (i.e. a param field for ANYTHING) it will still prompt for that parameter when I refresh the report. Am I crazy, or doing something wrong where crystal just doesn't let go of the field?
 

You won't be able to remove a parameter, formula, etc. if it's used anywhere in the report (green checkbox).

It may be in another formula, record selection, whatever, and sometimes it's pretty hard to find. Depending on your version you can right click on the object in the field explorer and select "Find in Formulas".

Another way is to edit the parameter and change the datatype - then when you refresh the report you'll probably get a datatype mismatch error and it will take you to the code in question. Good luck!

 
You have to remember to remove the parameter reference in the linking expert, and also go into each sub->report->selection formula->record and remove any references there.

-LB
 
What about removing a field that is used in another formula but that "other formula" is NOT IN the report? Its like if a formula is used in other formulas, and those "other formulas" are removed from being used in the report, those items still show as being IN the report (green check box).
 
Even fields from DB tables, the green check box is not remove and they are not used in ANY formulas.
 

Another trick is to export the report as Report Definition, then use the search function in Word or Notepad to look for the object name.

Everyone has gone through this and it can be very frustrating, but ultimately it's always in there somewhere.

 
I will try that, thanks Brian.

Dumb question though. What I DID try, I took one of the param fields, found every formula it was used in, deleted those formulas. Now when I do "find in formulas" it comes up with nothing, BUT it still has a check box and still prompts for the value when I refresh the report.
 

Then it's used in something other than a formula - could be a subreport link, embedded in a text object, no telling. But the report definition would probably catch it.

I feel your pain.
 
Understood. I literally mean I removed EVERYTHING from the report canvas. There is nothing in select record/group, nothing in any footers, the report literally returns zero records and it still prompts for the param fields.

Glad I'm not alone in this... to a degree I guess lol.

Thanks for the help guys, much appreciated.
 
If you are only looking for parameters used, change the datatype of the parameter. This will cause an error and take you to the location where it is being used.

When searching for fields/parameters used you need to check in formatting formulas (both field and section), and in the sort expert.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top