In Access, we can’t use CASE statement.
Alternatively, we can use Switch statement.
Usage
|
1 2 3 4 5 |
CASE x WHEN a THEN p WHEN b THEN q WHEN c THEN r ELSE y END |
The above code was written with Switch as follows.
|
1 |
Switch(x=a, p, x=b, q, x=c, r, True, y) |
It was said that Access employs Switch because of compatibility with VBA, but I don’t know actual reason.
Use iif
You can also use Iif. The following code leads same result.
|
1 |
iif(x=a, p, (iif(x=b, q, iif(x=c, r, y)))) |
Use Choose
It is a choice to use Choose, in some cases.
|
1 |
Choose(index, a, b, c, ...) |
index に整数を入れると、index = 1 なら a が、 index = 2 なら b が返ります。 整数でない場合は、一番近い整数に丸められます。 If index is less than 1, Null is returned.





