Chris Hohmann wrote:[color=blue]
> "shank" <shank@tampabay.rr.com> wrote in message
> news:ur0$cimbEHA.712@TK2MSFTNGP11.phx.gbl...[color=green]
>> Is the CASE statement allowed when querying an Access database?
>> Assuming so, what is the correct syntax?
>> thanks
>>
>> SELECT OrderNo, Description, Type, Label
>> FROM Stock
>> WHERE Manuf = 'M'
>> ORDER BY
>> CASE 'C' WHEN 'orderno_asc' THEN OrderNo END ASC,
>> CASE 'C' WHEN 'description_asc' THEN Description END ASC,
>> CASE 'C' WHEN 'type_asc' THEN Type END ASC,
>> CASE 'C' WHEN 'label_asc' THEN Label END ASC,
>> CASE 'C' WHEN 'orderno_asc' THEN OrderNo END DESC,
>> CASE 'C' WHEN 'description_asc' THEN Description END DESC,
>> CASE 'C' WHEN 'type_asc' THEN Type END DESC,
>> CASE 'C' WHEN 'label_asc' THEN Label END DESC
>>[/color]
>
> In addition to the IIF function Bob mentioned, you may also want to
> investigate the SWITCH function. The nested IIF functions could get
> pretty hairy in this particular situation. Bob, haven't we had this
> conversation before? :)
>
>[/color]
http://groups.google.com/groups?selm...TNGP09.phx.gbl[color=blue]
>[/color]
Guilty. I forgot about Switch again. However, in this case I do not think it
is appropriate unless all those columns have the same datatype.
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.