I do not have the right syntax but the technique is the same as in VFP.
I try this:
SELECT FirmID, FirmName, ShortPresentation,
iif(ZipCode = 'J2G 9H8',6,
iif( ZipCode = LEFT('J2G 9H8',5),5,
iif(ZipCode = LEFT('J2G 9H8',4),4,
iif(ZipCode = LEFT('J2G 9H8',3),3,
iif(ZipCode = LEFT('J2G 9H8',2),2,
iif(ZipCode = LEFT('J2G 9H8',1),1,0)))))) as MyCode
FROM Firms
ORDER BY MyCode
Simon, When you have a new question start a new thread.
We can then find the thread in the search with the title.
>Do not seem to work in Access 2k...
>
>I did :
>
> SELECT FirmID, FirmName, ShortPresentation
> FROM Firms
> ORDER BY
> CASE
> WHEN ZipCode = 'J2G 9H8' THEN 6
> WHEN ZipCode = LEFT('J2G 9H8',5) THEN 5
> WHEN ZipCode = LEFT('J2G 9H8',4) THEN 4
> WHEN ZipCode = LEFT('J2G 9H8',3) THEN 3
> WHEN ZipCode = LEFT('J2G 9H8',2) THEN 2
> WHEN ZipCode = LEFT('J2G 9H8',1) THEN 1
> ELSE 0
> END
> DESC
>
>
>But I get a Syntax Error.
>
>Any idea ?