Jan 12 2023 12:37 AM
Hello All,
Assume a table has columns Description, SO and Region.
Column5: Switch([description]=[SO],"L2L",[region]="Bangalore" Or "ROK","K2L",[region]="East" Or "West" Or "North" Or "South","L2L")
This is working fine for populating L2L (where I m saying if the values in Description and SO are same then return L2L) and K2L (where I am saying if region which is my 3 table has values - Bangalore or ROK, then update it to K2L).
The 3rd condition where I am saying if Region has values East or west or south or north then update them to O2L. This is not working. I even tried writing if the values are not Bangalore or ROK then update to L2L. I tried a combo of iif and switch. No luck.
The result is in a column where the possible values are L2L, K2L and O2L.
Please help.
Regards
Ganesh
+918451046072
Jan 12 2023 05:23 AM
Jan 12 2023 05:26 AM
SolutionHi,
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
Jan 12 2023 05:36 AM
Hi Arnel,
Copy/paste errors: 3 times the comma in "Or ,[region]" shouldn't be there.
Servus
Karl
****************
Access Bug Trackers
Access News
Access DevCon
Jan 12 2023 06:12 AM - edited Jan 12 2023 06:13 AM
@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 07:01 AM
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
Jan 13 2023 01:25 AM
Jan 13 2023 01:33 AM
Jan 13 2023 01:36 AM
Jan 13 2023 01:52 AM
Jan 12 2023 05:26 AM
SolutionHi,
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