开发者

how to pass null value when the parameters are left in empty

开发者 https://www.devze.com 2022-12-18 08:40 出处:网络
I am developing a Crystal Report from the database, and am setting a parameter\'s value in Crystal Reports itself, with a Command object. My issue is that when I run the Crystal Report, if I leave any

I am developing a Crystal Report from the database, and am setting a parameter's value in Crystal Reports itself, with a Command object. My issue is that when I run the Crystal Report, if I leave any parameter as null, it will return all the records from the datab开发者_运维百科ase. How is that possible?


If you're using parameters in a Database Command, you can't use optional parameters. However, if you're using CR2008 (I think that's when they were added), you can set your parameters as optional, and then use the HasValue() function to see if the user selected a value.

RecordSelection:

If HasValue({?MyParm}) Then
   {Command.MYFIELD} = {?MyParm}
Else
    True;


Crystal Reports requires each Parameter Field to have a value; nulls aren't allowed.

If you are using a Command object, you will need to use syntax like this in SQL:

--t-sql syntax; assumes numeric value and -1 is the value chosen to represent 'all values'
WHERE  table.field = CASE 
                       WHEN {?command_object_prompt} = -1 THEN table.field
                       ELSE {?command_object_prompt}
                     END

If you are using 'standard' database linking (as opposed to a Command object), look at my posting Crystal Reports: Optional-Multi-Select Parameters.

0

精彩评论

暂无评论...
验证码 换一张
取 消