Switch: If false do nothing (1 Viewer)

zoobeeda

Registered User.
Local time
Today, 15:30
Joined
Mar 30, 2014
Messages
28
I'm working with an Update Query using a Switch function such as follows.

Switch([field_1]="red", "01",
[field_1]="yellow", "02",
[field_1]="blue","03])

The problem is that if the condition is false, meaning the value is neither red, yellow or blue, the Switch function will actually delete whatever value there may be in the field that is being populated with either 01, 02 or 03. How would I write in a string at the end of this formula something meaning roughly:

If false, do nothing.

This means that if the value encountered is neither red, yellow or blue, do nothing to the number column—specifically, that Access should not delete any values that may be in the corresponding number field.

I'm assuming this could be done simply. Me newbie with limited scripting abilities.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:30
Joined
May 7, 2009
Messages
19,249
IIF(ISNULL(Switch([field_1]="red", "01", [field_1]="yellow", "02", [field_1]="blue","03")), "SomethingElse", Switch([field_1]="red", "01", [field_1]="yellow", "02", [field_1]="blue","03"))

or

IIF(ISNULL(Switch([field_1]="red", "01", [field_1]="yellow", "02", [field_1]="blue","03")), [field_1], Switch([field_1]="red", "01", [field_1]="yellow", "02", [field_1]="blue","03"))

or

IIF(Instr("/blue/red/yellow/", [field_1] & "")<>0, Switch([field_1]="red", "01", [field_1]="yellow", "02", [field_1]="blue","03"), "SomethingElse")

or

IIF(Instr("/blue/red/yellow/", [field_1] & "")<>0, Switch([field_1]="red", "01", [field_1]="yellow", "02", [field_1]="blue","03"), [field_1])
 
Last edited:

Users who are viewing this thread

Top Bottom