default value for switch in access 2007

Mandeep Singh picture Mandeep Singh · Apr 30, 2013 · Viewed 18.9k times · Source

I am using switch statement in access 2007, i want to know how I can specify default value

select 
  switch
  (
  MyCol = 1, 'Value is One',
  MyCol = 2, 'Value is Two'
  ) from MyTable

Thanks

Answer

jainvikram444 picture jainvikram444 · Apr 30, 2013
SELECT
Switch(MyTable.[MyCol]='1','Terrestrial',
MyTable.[MyCol]='2','Value is two',MyTable.[MyCol]='3','Value is three',
True,'Error') AS ColumnName
FROM MyTable;