lcallah93
asked on
Blank Date Parameters
I have created a report that lists cash deposits by date range. I currently have a default report scheduled on Crystal Server to run with hard-coded dates for the current fiscal year. What I would like to do is let the dates default to the current fiscal year if left blank.
I have created two formulas in the report that calculate the first and last day of the current fiscal year.
Start Date:
BeforeReadingRecords;
if month(currentdate)<6
then date((year(currentdate)-1) ,07,01)
else date((year(currentdate)),0 7,01)
End Date:
BeforeReadingRecords;
if month(currentdate)>7
then date((year(currentdate)+1) ,06,30)
else date((year(currentdate)),0 6,30)
I then created two formulas to populate the parameters with that date (or so I thought) if the parameters were left blank:
BeforeReadingRecords;
if not hasvalue ({?Start Date})
then {?Start Date}={@Fiscal Year Start Date}
BeforeReadingRecords;
if not hasvalue({?End Date})
then {?End Date}={@Fiscal Year End Date}
Then in my selection criteria I put in the following:
{gifts_full.gifteffdat} in {?Start Date} to {?End Date}
However, I get a 'parameter has no value' error when running the report.
Has anyone done anything like this before and if so, how did you solve the problem?
Thank you!
Lisa
I have created two formulas in the report that calculate the first and last day of the current fiscal year.
Start Date:
BeforeReadingRecords;
if month(currentdate)<6
then date((year(currentdate)-1)
else date((year(currentdate)),0
End Date:
BeforeReadingRecords;
if month(currentdate)>7
then date((year(currentdate)+1)
else date((year(currentdate)),0
I then created two formulas to populate the parameters with that date (or so I thought) if the parameters were left blank:
BeforeReadingRecords;
if not hasvalue ({?Start Date})
then {?Start Date}={@Fiscal Year Start Date}
BeforeReadingRecords;
if not hasvalue({?End Date})
then {?End Date}={@Fiscal Year End Date}
Then in my selection criteria I put in the following:
{gifts_full.gifteffdat} in {?Start Date} to {?End Date}
However, I get a 'parameter has no value' error when running the report.
Has anyone done anything like this before and if so, how did you solve the problem?
Thank you!
Lisa
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for checking how the data is pulled. I did check to see that the figures matched (which they did) but I failed to check on how the records were generated.
Thank you!
Thank you!
Might be worth verifying if the dates are being passed.
Run the report in the designer then
Click DATABASE --> SHOW SQL
If the dates show in the query then they are being passed.
If they don't then try Kurt's method. If that passes them to the database then you probably should ask this to be reopened and include his comment in the accepted answer
mlmcc
Run the report in the designer then
Click DATABASE --> SHOW SQL
If the dates show in the query then they are being passed.
If they don't then try Kurt's method. If that passes them to the database then you probably should ask this to be reopened and include his comment in the accepted answer
mlmcc
ASKER
The dates are being passed - the query is below.
SELECT "gifts_full"."gifteffdat", "gifts_full"."giftamount", "gifts_full"."giftdeduct", "gifts_full"."giftnonded", "division"."table_code", "gifts_full"."giftrest", "division"."table_type", "division"."table_val", "solicitations"."sol_val", "solicitations"."sol_code" , "gifts_full"."giftsource", "gifts_full"."giftid", "names_VIEW_preferred"."na meformn", "gifts_full_1"."gifteffdat ", "names_VIEW_preferred"."na mesmashd", "gifts_VIEW_released_for_r eporting". "giftkey", "gifts_full"."gifttype", "gifts_full"."giftlook1"
FROM ((((("VCU"."dbo"."names_VI EW_preferr ed" "names_VIEW_preferred" LEFT OUTER JOIN "VCU"."dbo"."gifts_full" "gifts_full" ON "names_VIEW_preferred"."na meid"="gif ts_full"." giftid") LEFT OUTER JOIN "VCU"."dbo"."chart_of_acco unts" "chart_of_accounts" ON "gifts_full"."giftrest"="c hart_of_ac counts"."c hart_code" ) LEFT OUTER JOIN "VCU"."dbo"."gifts_full" "gifts_full_1" ON "gifts_full"."giftplgkey"= "gifts_ful l_1"."gift key") LEFT OUTER JOIN "VCU"."dbo"."gifts_VIEW_re leased_for _reporting " "gifts_VIEW_released_for_r eporting" ON "gifts_full"."giftkey"="gi fts_VIEW_r eleased_fo r_reportin g"."giftke y") LEFT OUTER JOIN "VCU"."dbo"."solicitations " "solicitations" ON "gifts_full"."giftsolic"=" solicitati ons"."sol_ code") LEFT OUTER JOIN "VCU"."dbo"."division" "division" ON "chart_of_accounts"."chart _div"="div ision"."ta ble_code"
WHERE ("gifts_full"."gifteffdat" >={ts '2010-07-01 00:00:00'} AND "gifts_full"."gifteffdat"< {ts '2011-07-01 00:00:00'}) AND ("gifts_full"."gifttype"=' b' OR "gifts_full"."gifttype"='g ' OR "gifts_full"."gifttype"='y ') AND "gifts_VIEW_released_for_r eporting". "giftkey" IS NOT NULL AND ("gifts_full"."giftlook1" IS NULL OR "gifts_full"."giftlook1"<> 'ng')
SELECT "gifts_full"."gifteffdat",
FROM ((((("VCU"."dbo"."names_VI
WHERE ("gifts_full"."gifteffdat"
No data values can satisfy these conditions...
WHERE ("gifts_full"."gifteffdat" >={ts '2010-07-01 00:00:00'} AND "gifts_full"."gifteffdat"< {ts '2011-07-01 00:00:00'})
WHERE ("gifts_full"."gifteffdat"
ASKER
I am getting all gifts greater than or equal to 7/1/2010 but less than 7/1/2011. I have to admit that I still confuse the <> symbols - is that not what the equation says?
Apologies; you're right - I didn't pick up the difference in years even reading it several times!!!
ASKER
No worries - it happens to me WAY to much...
When I read you rcomment peter, I had to triple check to ensure the dates really were different and in the correct order.
mlmcc
mlmcc
I suspect CR had the same problem...(:-)
What version of Crystal?
mlmcc