Switch function in AccessPosted: July 25, 2007
Switch(Expression1, What To Do If Expression1 Is True, Expression2, What To Do If Expression2 Is True, Expression_n, What To Do If Expression_n Is True) As SomeValue
Unlike IIf(), the Switch() function does not take a fixed number of arguments. It takes as many combinations of <Expression -> Statement>s as you need. Each expression is evaluated. If the expression evaluates to true, the statement that follows it executes.
The solution for the user is:
SELECT * FROM (SELECT id, TalkMonth, CINT(Switch([TalkMonth]='January',1,
[TalkMonth] is NULL,999)) As TalkMonthNumber
ORDER BY TalkMonthNumber
And use the new numeric column in SortExpression for the string column.
<asp:BoundField DataField="TalkMONTH" HeaderText="TalkMONTH" SortExpression="TalkMonthNumber" />
However,it seems that Switch can only go upto level 14 for nesting.