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 a value from main to subReport in Crystal 11

Status
Not open for further replies.

kratz

Programmer
Nov 17, 2006
35
US
I have a report where the input parameter passed to the main report is passed down to two subreports. I'm trying to find a way to pass a calculated date instead of the input date, but the "Change Subreport Links" window does not allow me to do that. I don't know what I'm doing wrong.
Is there a way to schedule a report in InfoView so that a date parameter is calculated prior to the report running?
 
Yes, and if you are referencing a formula you tried, post it.

The common approach is as follows:

Set a default value for the date parameter of 1/1/1970

Now create a formula of:

if {?MyDateParm} =cdate(1970,1,1) then
currentdate-7
else
{?MyDateParm}

In this I used the date -7 to demonstrate. You've posted nothing specific in your post about what this calculated date is, such a vague post shouldn't expect any responses at all other than asking you to specifcally stte what you want, but this should explain the methodology.

Note also that this formula allows for calculating if they use the default, or if they pass something it will use that.

-k
 
Thank you for trying to help.
The problem I have is not with the formula, but with the mechanism for passing a parameter from the main report to a subreport. One does this via ChangeSubreportLinks; and in that window I don't find any way to associate the receiving parameter name (already existing within the subreport) with a formula even when that formula is merely equating to the main reports parameter which is a date.
(Although I'm the same person who was seeking help with making a date formula, that is no longer a problem. So there was no reason to toss in a red herring to distract potential advisors from the actual problem which I described.)
 
Hi Krats,

Place Whileprintingrecords; in your date calculation formula and select this formula from available fields, and you can see your parameter under "subreports parameter field to use" at the bottom, provided your formula return type and parameter type is same.

Hope this helps!

Thank You
keerthana!
 
You do need to show the contents of the formula you are trying to use for linking, and also identify what you are trying to link to in the subreport. Please explain why the parameters cannot be set up with the same name and datatype in each (which would then allow you to link them together).

-LB
 
KeertanaCR,
Thank you.
The ChangeSubreportLinks window does show my calculated field, but when I select that the window does not show the subreport's input parameter which is what I wanted to link to.
LBASS,
Thank you.
The report as I received it had a parameter of type date (not datetime) called ReportDate. My calculation considered entirely of "formula = ReportDate" (in Basic).
I wondered whether KeertanaCR's last point might had been appropo, but I assume that results from the formula would be the same data type as the input. If not, I think Crystal XI has a bug.

Anyway, I gave up trying to change the linkage, and just created a duplicate formula in each subreport. And now the report works fine (once I realized that the output of Dateadd is not a date but a datetime). So I'd like to close this Thread.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top