on 01-08-2014 8:45 AM
Hi!
I used SAP Crystal Reports 2008 to design a report.
I have 2 parameter fields which are displayed in the Selection Criteria Screen when the report is run:
(a) @Project
(b) PrefrdSortOrder
(a) For @Project, the User selects his project from a drop-down list
(b) For PrefrdSortOrder, the user can select one of 2 values :
- Original Order or
- Description
i.e the user can select how he wants the report to be sorted.
Normally, most users want the report to be sorted by "Original Order". Only rarely will a user want the report to be sorted by "Description"
My report works well until I make the following change....
If the User does not select a value, i.e if he leaves the "PredrdSortOrder" prompt BLANK, I want CR to behave as if the User has selected "Original Order", and sort the report in Original Order
However, I get this error message:
Error in Formula 'YourPreferredSortOrder_sv'
Parameter has no value
------------------
Note :
'YourPreferredSortOrder_sv is a Shared variable and its code is:
WhilePrintingRecords;
Shared StringVar YourPreferredSortOrder_sv;
IF {?PrefrdSortOrder} = 'Original Order' THEN 'Original (Line Num) Order'
ELSE IF
TOTEXT ({?PrefrdSortOrder}) = " " THEN 'Original (Line Num) Order' // <- Apparently the error is here!
ELSE IF
{?PrefrdSortOrder} = 'Description' THEN 'By Item Desc (Alphabetic)'
---------
Can anyone help me?
Thanks
Leon lai
Hi Leon,
Try this formula ,
IF {?PrefrdSortOrder} = 'Original Order' THEN 'Original (Line Num) Order'
ELSE IF
Not hasvalue ({?PrefrdSortOrder}) THEN 'Original (Line Num) Order'
ELSE IF
{?PrefrdSortOrder} = 'Description' THEN 'By Item Desc (Alphabetic)'
Make sure that parameter Optional Prompt is True.
-Rajesh N
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rajesh,
I experimented with your suggestion in all possible ways. I am glad to inform you that I found the answer by accident.
We must simply put the HASVALUE formula FIRST ON THE LIST like this:
IF Not hasvalue ({?PrefrdSortOrder}) THEN 'Original (Line Num) Order'
ELSE IF {?PrefrdSortOrder} = 'Original Order' THEN 'Original (Line Num) Order'
ELSE IF
{?PrefrdSortOrder} = 'Description' THEN 'By Item Desc (Alphabetic)'
THEN IT WORKS PERFECTLY.
I don't know why, but it works.
It seems that the HASVALUE formula must always be evaluated FIRST
So, many thanks for hinting the correct solution, and I'm marking your answer as CORRECT (even if not 100% correct)!
BEST REGARDS
Leon
It works this way because "Has Value" checks for a null value. Null is not a value as such and comparing anything to null doesn't evaluate to either true or false. For more information about how this works, you can see my post here: What is Null and Why is it Important for Crystal Reports | SAP BI BLOG
-Dell
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.