Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested if else in Crystal Reports

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"
like image 281
Himanshu Jansari Avatar asked Jun 25 '12 06:06

Himanshu Jansari


People also ask

Can you nest if else statements?

Nested if statements A nested if statement is an if statement placed inside another if statement. Nested if statements are often used when you must test a combination of conditions before deciding on the proper action.


1 Answers

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";
like image 113
Arvo Avatar answered Oct 16 '22 10:10

Arvo