Paks
Paks

Reputation: 1470

If clause is not working as expected

I have the following if clause:

if ucase(displayanzeige) = "Y" \
or isnull(displayanzeige)      \
and ucase(bstatus) = "2"       \
or ucase(bstatus) = "1"

The first part of the if clause is working:

if ucase(displayanzeige) = "Y" \
or isnull(displayanzeige)

But the second part is not working:

and ucase(bstatus) = "2"      \
or ucase(bstatus) = "1"

What is wrong with the if-clause? please help

Upvotes: 4

Views: 82

Answers (2)

Curtis
Curtis

Reputation: 103348

Use brackets to help identify your if conditions:

if (ucase(displayanzeige) = "Y" or isnull(displayanzeige))
    and (ucase(bstatus) = "2" or ucase(bstatus) = "1")

You currently have:

1 or 2 and 3 or 4

The system could interpret this as "1 must be true or 2 and 3 or 4 must be true"

Placing brackets like:

(1 or 2) and (3 or 4)

Will tell the system that "1 or 2 must be true, and 3 or 4 must be true"

Upvotes: 4

Rahul Tripathi
Rahul Tripathi

Reputation: 172448

Using brackets is a solution to your problem:-

 if (ucase(displayanzeige) = "Y" or isnull(displayanzeige)) and (ucase(bstatus) = "2" or ucase(bstatus) = "1")

Presently the system could not interpret the conditions as you want it to be. Using brackets is a better option for you.

Upvotes: 2

Related Questions