Reputation: 32612
I want to nest if-else statements in Crystal Reports, but I don't know the necessary syntax. How can I arrange something like this:
if table1.id <> "1" then
if table1.name <> "a" then
var1 := "Hello"
else
var1 := "Hi"
else
var1 := "Bye"
Upvotes: 15
Views: 66759
Reputation: 4253
You can also nest your nested if statements and end with a semicolon on the last condition.
Stringvar variable
if {@cond}=1 then
variable:="cond1"
else
if {@cond}=2 then
variable:="cond2"
else
variable:="otherwise";
variable
Upvotes: 0
Reputation: 10580
You can use parenthesises to avoid ambiguity within nested if..else
structures:
if {table1.id} <> 1 then
(if {table1.name} <> "a" then
var1 := "Hello"
else
var1 := "Hi";)
else
var1 := "Bye";
Upvotes: 26