cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Reports not Passing current date to subreport

Former Member
0 Kudos

Dear experts, I am trying to pass the current date values to parameters in a Crystal Report that feeds a sub-report but the following code does not make the change intended:

// {?FiscalYear} default value is 9999

If {?FiscalYear} = 9999 then {?FiscalYear} = Year(CurrentDate); {?FiscalMonth} = Month

(CurrentDate); Else...

It does not fail with any error message but it doesn't bring out any data either. When checked the value of {?FiscalYear} is unchanged = 9999.

What am I doing wrong?

Thank you!

erollano

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Ian,

Not sure where you are going with this, but I am not trying to filter any data but test the in Selection Record formula, the user's input -say 2016 but if the user left the default, 9999, then load the {?FiscalYear} with the current year.

e

Former Member
0 Kudos

In order to test the Record selection formula you have to filter data. Otherwise nothing will happen and your test will be inconclusive.

Ian

Former Member
0 Kudos

But you are still not filtering any data

Select statement should look like..

(If {?FiscalYear} = 9999 then {FiscalYearField} = @CurrentYear else {FiscalYearField} ={?FiscalYear})

and

(If {?FiscalYear} = 9999 then {FiscalMonthField} = @CurrentMonth else {FiscalMonthField} ={?FiscalMonth}))

and ... remaining select filters

Ian

Former Member
0 Kudos

My apologies.

{?FiscalYear} is a parameter type Number that users can change it to any valid year i.e.: 2017 so this value passes to the sub-report to bring in the data for that year.

The intention here is, by setting the Parameter to 9999 as Default, enable it to change automatically to Current Year if no change was made.

So this is the current Record Selection formula, where dates @CurrentYear and @CurrentMonth where converted values (ToNumber(Year(CurrentDate) and ToNumber(Month(CurrentDate):

If {?FiscalYear} = 9999 then ( {?FiscalYear} = @CurrentYear; ; {?FiscalMonth} = @CurrentMonth; ) Else...(the regular selection with an entered year and month values)

It does not fail with any error message but it doesn't bring out any data either. When checked the value of {?FiscalYear} is unchanged = 9999 (it should be 2017 which is the value in @CurrentYear, and brings back no valid data.

Hope this is clearer now.

Thanks,

Erollano

Former Member
0 Kudos

If this is in your select statement

If {?FiscalYear} = 9999 then {?FiscalYear} = Year(CurrentDate); {?FiscalMonth} = Month

(CurrentDate); Else...

It will not work as its not filtering any data. If its a formula you need to show all text and explain how you plan to use it to filter data in Subreport

Ian