jollyreaper
Technical User
I'm calculating the current accounting period to use in several sub-reports. The slow and dirty way to do this is to just put that formula in every sub-report and things will work fine. I wanted to make this quick and elegant by calculating the formula once in the main report, then passing it to the sub-reports. However, this is generating errors.
Formula from main report (Formula called CurrentPeriodFN):
Shared PeriodMonth, PeriodYear, CurrentPeriod As Number
PeriodMonth = Month (CurrentDate)
PeriodYear = Year (CurrentDate)
CurrentPeriod = PeriodMonth + (12 * PeriodYear) - 1
formula = PeriodMonth + (12 * PeriodYear) - 1
(Note: I completely suck at Crystal. I'm still conflustered by the differences between basic and crystal syntax.)
As I understand it, I cannot make the formula CurrentPeriodFN but I can declare a variable as shared and do the same thing.
So, according to the books, the way to make that variable value available in the sub-report is to define it there.
So, in the sub-report, formula is called CurrentPeriodFN and contains:
Shared CurrentPeriod As Number
formula=CurrentPeriod
For some reason this isn't working. Either a value of zero is getting passed or nothing is passed and null defaults to zero in the whacky world of Crystal.
What's more, if I include that value in a SQL statement, I get more than just a SQL error.
Here's the formula from the editor.
{GLACCTS.AN} in "40010" to "40090" and
{GLACCTS.AN} <> "40030" and
{GLACCTSA.CAP} = {@CurrentPeriodFN}
"The formula cannot be used because it must be evaluated later"
There's a whole KB article about it.
So, is what I'm describing even doable or should I default to the slow and dirty way instead?
Formula from main report (Formula called CurrentPeriodFN):
Shared PeriodMonth, PeriodYear, CurrentPeriod As Number
PeriodMonth = Month (CurrentDate)
PeriodYear = Year (CurrentDate)
CurrentPeriod = PeriodMonth + (12 * PeriodYear) - 1
formula = PeriodMonth + (12 * PeriodYear) - 1
(Note: I completely suck at Crystal. I'm still conflustered by the differences between basic and crystal syntax.)
As I understand it, I cannot make the formula CurrentPeriodFN but I can declare a variable as shared and do the same thing.
So, according to the books, the way to make that variable value available in the sub-report is to define it there.
So, in the sub-report, formula is called CurrentPeriodFN and contains:
Shared CurrentPeriod As Number
formula=CurrentPeriod
For some reason this isn't working. Either a value of zero is getting passed or nothing is passed and null defaults to zero in the whacky world of Crystal.
What's more, if I include that value in a SQL statement, I get more than just a SQL error.
Here's the formula from the editor.
{GLACCTS.AN} in "40010" to "40090" and
{GLACCTS.AN} <> "40030" and
{GLACCTSA.CAP} = {@CurrentPeriodFN}
"The formula cannot be used because it must be evaluated later"
There's a whole KB article about it.
So, is what I'm describing even doable or should I default to the slow and dirty way instead?