Rchee
Rchee

Reputation: 113

How to perform basic OR and AND conditioning in IF statement in Access

Like the title says, I'm just trying to use OR and AND conditions within my IF statement in access, for example:

iif(A=" " OR A=0 AND B>=2,"Test1","Test2")

I'm trying to figure out what the correct way to write this would be.

Thanks in advance.

Upvotes: 0

Views: 56

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269843

I think you just want parentheses:

iif( (A = " " OR A = 0) AND B >= 2, "Test1", "Test2")

However, this does not really make sense. Is A a number or a string? If a string, then all comparisons should be to strings:

iif( (A = " " OR A = "0") AND B >= 2, "Test1", "Test2")

If both are numbers, then the comparison to " " is meaningless. You probably want to compare to NULL:

iif( (A is null OR A = 0) AND B >= 2, "Test1", "Test2")

Upvotes: 1

Related Questions