Home > Software design >  Switch function in update query
Switch function in update query

Time:10-07

I have a table that gets appended with data. The columns are always the same. One column displays Employee_Type. When I append data it is displayed as 1, 2, 3 or 4. 1=None, 2=Employee, 3=Contractor, 4=Visitor. I want an update query to run each morning. I was trying an update query where the Update To field said :

Switch("1","None","2","Employee","3","Contractor","4","Visitor")

However, it just changes all cells to None, regardless of value. Can anyone help me, or give a better way?

enter image description here

CodePudding user response:

You should use Choose for this:

Choose([Employee_Type],"None","Employee","Contractor","Visitor")

CodePudding user response:

I'm assuming you have defined Employee_Type as Text.

Then Switch() should be called as

Switch(<employee type field>="1", "None", ...)

Since the first conditional test is

"1"

Which will always be non-zero, and therefore return True.

You have not specified which field you are testing for "1", "2", "3", "4".

Also is that field a of type Text or is it a Number?

If it is a Number, then you need to change to:

Switch(<employee type field>=1,"None", ...)
  • Related