Forum Discussion
Switch function in Access is not evaluating more than 2 conditions
- Jan 12, 2023
Hi,
The syntax for the OR operator is wrong. You would have to repeat the full comparison for every value, i.e. [region]="Bangalore" Or [region]="ROK" etc. With more than 1 value it's easier to use the IN operator. If I understand your intention correctly, then this should work:
Switch([description]=[SO],"L2L",[region] IN ("Bangalore", "ROK"),"K2L",[region] IN ("East", "West","North","South"),"L2L")
Servus
Karl
****************
Access Bug Trackers
Access News
Access DevCon
Hi,
The syntax for the OR operator is wrong. You would have to repeat the full comparison for every value, i.e. [region]="Bangalore" Or [region]="ROK" etc. With more than 1 value it's easier to use the IN operator. If I understand your intention correctly, then this should work:
Switch([description]=[SO],"L2L",[region] IN ("Bangalore", "ROK"),"K2L",[region] IN ("East", "West","North","South"),"L2L")
Servus
Karl
****************
Access Bug Trackers
Access News
Access DevCon
- Ganesh99Jan 13, 2023Copper Contributor
Hi Karl!
Daaaaaw!! Thanks. It worked like a charm. It was a very simple thing for you but it was such a **bleep** for me these few days. Thanks a ton. I shall pledge to tell this all who want it and pass on the credits to you.
Regards
Ganesh
+918451046072 - XPS35Jan 12, 2023Iron Contributor
Karl
You copied the one of OP's errors. I think it should be:
Switch([description]=[SO],"L2L",[region] IN ("Bangalore", "ROK"),"K2L",[region] IN ("East", "West","North","South"),"O2L")
@Ganesh
I am not sure what you want. If the first condition ([description]=[SO]) is true "L2L" is returned, no matter what region. Is that what you want.- Jan 12, 2023
Hi,
Copy/paste and typos are responsible for the majority of errors in all programs. Far behind come syntax and logic.
🙂
Karl
****************
Access Bug Trackers
Access News
Access DevCon