Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula error with NULL result Post Reply Post New Topic
Author Message
kezza
Newbie
Newbie


Joined: 08 Mar 2012
Location: Netherlands
Online Status: Offline
Posts: 19
Quote kezza Replybullet Topic: Formula error with NULL result
     Posted: 21 Aug 2014 at 1:41am
Hello everyone,

I have a report with a formula field. But when this field is NULL (empty) i want  to show a result of another formula.

So by the Display String I have made the following formula, but then I get the error  "A statement is expected here"

Here is the formula:
if {@formula1} ="" then {@formula2}
else {@formula1}


Thanx!
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 21 Aug 2014 at 2:01am
if isnull({@formula1}) then {@formula2}
else {@formula1}
IP IP Logged
kezza
Newbie
Newbie


Joined: 08 Mar 2012
Location: Netherlands
Online Status: Offline
Posts: 19
Quote kezza Replybullet Posted: 21 Aug 2014 at 2:26am
Thank you, but I still get the error. I'm using Basic Syntax
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 21 Aug 2014 at 2:40am
try changing to it crystal syntax?
IP IP Logged
kezza
Newbie
Newbie


Joined: 08 Mar 2012
Location: Netherlands
Online Status: Offline
Posts: 19
Quote kezza Replybullet Posted: 21 Aug 2014 at 2:56am
Then I get the error: the formula result must be a string
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 21 Aug 2014 at 3:10am
is the result of {@formula2} a string, and {@formula1} something else?

You can fix that by changing the formula to:
if isnull({@formula1}) then {@formula2}
else totext({@formula1})
IP IP Logged
kezza
Newbie
Newbie


Joined: 08 Mar 2012
Location: Netherlands
Online Status: Offline
Posts: 19
Quote kezza Replybullet Posted: 21 Aug 2014 at 4:09am
They are both numberfields. The formula you mentioned won't work either. Error: a number is required here
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 21 Aug 2014 at 4:17am
Okay ignore the last part (to totext).
When you are getting the error message, is it referring you to part of the formula?
IP IP Logged
kezza
Newbie
Newbie


Joined: 08 Mar 2012
Location: Netherlands
Online Status: Offline
Posts: 19
Quote kezza Replybullet Posted: 21 Aug 2014 at 4:35am
When i ignore the last part i get "the formula result must be a string" It's not referring to a part of the formula
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 21 Aug 2014 at 8:16am
what is the syntax for formula1 and formula2?
and if they referance more formula please include those.
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