Skip to Content
0

Crystal Reports not Passing current date to subreport

Apr 10, 2017 at 06:12 PM

53

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Ian Waterman Apr 11, 2017 at 08:13 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Apr 11, 2017 at 03:52 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Ian Waterman Apr 11, 2017 at 04:05 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Apr 12, 2017 at 03:42 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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

Ian

0