CASE WHEN in ACCESS

P

Paul C.

Hi folks. I am trying to do as CASE WHEN type statement in MS-Access. In
SQL Server, it would be written like this: SELECT CASE FirstName WHEN NULL
THEN 'Unassigned' ELSE FirstName END FROM MyTable

I have searched this newsgroup, but couldn't find any postings for this.
Does anyone know how to do this in Access?

I have tried it, and it gives me a syntax error.

Thanks so much.
 
M

MGFoster

Paul said:
Hi folks. I am trying to do as CASE WHEN type statement in MS-Access. In
SQL Server, it would be written like this: SELECT CASE FirstName WHEN NULL
THEN 'Unassigned' ELSE FirstName END FROM MyTable

I have searched this newsgroup, but couldn't find any postings for this.
Does anyone know how to do this in Access?

I have tried it, and it gives me a syntax error.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

SELECT Nz(FirstName,"Unassigned") As FName

Nz() is sorta like the T-SQL function ISNULL().

OR

SELECT IIf(FirstName Is Null, "Unassigned", FirstName) As FName

IIf(expression, True result, False result) is usually used for the CASE
statement. IIf() can be nested.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQjZJ1IechKqOuFEgEQLH6ACfXTChLR+dxy34p/S65b1rp6+o2p0AnR+l
+69uvsyqF8C0PKM7TSsjIMO5
=Y0VJ
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top