Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Distinction between null and zero Post Reply Post New Topic
Author Message
darek
Newbie
Newbie


Joined: 03 Apr 2009
Online Status: Offline
Posts: 3
Quote darek Replybullet Topic: Distinction between null and zero
     Posted: 03 Apr 2009 at 12:50am
Hi,

I have a problem with distinction between database nulls and zeros. I want to have in my report '-' character when null and 0 when zero.
Is there a possibility to do that?

Thank you in advance.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 03 Apr 2009 at 6:31am
in the report, you would want to create a formula and in it you would want something like:
 
if isnull({table.field}) then
  "-"
else
  {table.field}
 
that should do.
IP IP Logged
darek
Newbie
Newbie


Joined: 03 Apr 2009
Online Status: Offline
Posts: 3
Quote darek Replybullet Posted: 03 Apr 2009 at 6:42am
Unfortunately it doesn't work, because the data is of type Number.
If I do like you suggest, an error occurs by {table.field} and says that string is required.
CR doesn't allow mixing data types.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 03 Apr 2009 at 6:58am
if isnull({table.field}) then
  "-"
else
  totext({table.field})
 
if you want no decimals:
if isnull({table.field}) then
  "-"
else
  totext({table.field},0)
IP IP Logged
darek
Newbie
Newbie


Joined: 03 Apr 2009
Online Status: Offline
Posts: 3
Quote darek Replybullet Posted: 03 Apr 2009 at 7:14am
It works.

Thanks a lot.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 03 Apr 2009 at 7:25am
Thanks DBlank...should have realized that totext was needed as the value was 0...but I was more focused on the ISNULL part.
 
lockwelle
IP IP Logged
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