Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Need code for avoid null values Post Reply Post New Topic
Author Message
skattempudi
Newbie
Newbie


Joined: 22 Jun 2018
Location: India
Online Status: Offline
Posts: 2
Quote skattempudi Replybullet Topic: Need code for avoid null values
    Posted: 24 Jun 2018 at 11:26pm
Hi Experts,

I am working on CR2016 designer.

I have one optional prompt on Comments field, but my requirement is, if user don't enter any value in prompt it should bring all values, other wise he has to bring only which are not null values in comments field along with remaining report fields.

I am trying to write below code

(not HasValue({?Comments}) = {Command.ZCOMMENTS})
or
(HasValue({?Comments}) = (not HasValue {Command.ZCOMMENTS})

but throwing "The ) missing" error is coming


Your help should be appreciated.

Edited by skattempudi - 24 Jun 2018 at 11:29pm
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 25 Jun 2018 at 4:32am
I am assuming that this formula is in the select expert.  So if you want to select all the records if a user does not enter a prompt then it normally (for me) looks something like this.

if hasValue({?Comments}) then {?Comments} = {Command.ZCOMMENTS}

the hasValue function is a boolean value, so it returns a true or false.  Thus since you only want to filter when a value is entered, you would put the condition in when hasValue is true.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Jun 2018 at 4:35am
why not make the prompt a Yes/No drop down

({?Comments}='No'
or
({?Comments}='Yes' and NOT(ISNULL({Command.ZCOMMENTS})))


If you want to keep what you have I am not sure what they are putting into the ?Comments option but try this
(
not (HasValue({?Comments}))
or
(HasValue({?Comments}) and NOT (ISNULL({Command.ZCOMMENTS})))
)
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Jun 2018 at 4:37am
oops - Sorry Kevlray, didn't mean to double answer - was typing when you posted :)
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 25 Jun 2018 at 12:46pm
No problem.  Better two good answers instead no answers or a bad answer :-)
IP IP Logged
skattempudi
Newbie
Newbie


Joined: 22 Jun 2018
Location: India
Online Status: Offline
Posts: 2
Quote skattempudi Replybullet Posted: 26 Jun 2018 at 7:59pm
Hello,

Thank you so much for your Help.

I am able to pull all values in ZCOMMENTS field data if "comments" parameter is null by Making Optional parameter. But I want If I keep any value in "comments" parameter then I want all not null values in ZCOMMENTS.

Could you please help me out this.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 Jun 2018 at 3:34am
Did you try this...?

(
not (HasValue({?Comments}))
or
(HasValue({?Comments}) and NOT (ISNULL({Command.ZCOMMENTS})))
)
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.