Need code for avoid null values

Printed From: Crystal Reports Book — Forum Name: Technical Questions

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
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.
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})))
)
oops - Sorry Kevlray, didn't mean to double answer - was typing when you posted :)
No problem.  Better two good answers instead no answers or a bad answer :-)
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.
Did you try this...?

(
not (HasValue({?Comments}))
or
(HasValue({?Comments}) and NOT (ISNULL({Command.ZCOMMENTS})))
)