Print Page | Close Window

Need code for avoid null values

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22633
Printed Date: 29 Apr 2024 at 4:18pm


Topic: Need code for avoid null values
Posted By: skattempudi
Subject: Need code for avoid null values
Date 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.



Replies:
Posted By: kevlray
Date 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.


Posted By: DBlank
Date 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})))
)


Posted By: DBlank
Date Posted: 25 Jun 2018 at 4:37am
oops - Sorry Kevlray, didn't mean to double answer - was typing when you posted :)


Posted By: kevlray
Date Posted: 25 Jun 2018 at 12:46pm
No problem.  Better two good answers instead no answers or a bad answer :-)


Posted By: skattempudi
Date 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.


Posted By: DBlank
Date Posted: 27 Jun 2018 at 3:34am
Did you try this...?

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



Print Page | Close Window