IIf Function with "Or"

K

ktwtennis

I am trying to get a function something like this:

Proj ID: IIf(([WoProjCode]="" or "99Z9999"),"09RM003",[WoProjCode])

If the project ID is blank or "99Z9999", I want it to go to "09RM003", and
if not, then default to its own project ID.

Many thanks for any help you can provide!
 
M

MGFoster

ktwtennis said:
I am trying to get a function something like this:

Proj ID: IIf(([WoProjCode]="" or "99Z9999"),"09RM003",[WoProjCode])

If the project ID is blank or "99Z9999", I want it to go to "09RM003", and
if not, then default to its own project ID.

Many thanks for any help you can provide!

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

Posting your question over and over doesn't encourage people to answer.
Just check you previous post - they have been answered.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

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

iQA/AwUBSZM/XYechKqOuFEgEQKnHgCfb5moEPe4n04BkGOqWMqijHqxOWIAoI/o
TiOniuGMRA4/qb8W9vOmA55S
=7SdR
-----END PGP SIGNATURE-----
 
J

John W. Vinson

I am trying to get a function something like this:

Proj ID: IIf(([WoProjCode]="" or "99Z9999"),"09RM003",[WoProjCode])

If the project ID is blank or "99Z9999", I want it to go to "09RM003", and
if not, then default to its own project ID.

Many thanks for any help you can provide!

The OR is a Boolean algebra operator, not an English language conjunction: it
needs to compare two true/false expressions, not two values. In addition,
unless you (unwisely usually) have WoProjCode set to Allow Zero Length
Strings, it will never be equal to ""; it will instead be NULL.

You can solve both problems with the NZ() function:

IIF(NZ([WoProjCode], "99Z9999") = "99Z9999", "09RM003", [WoProjCode])
 
J

John W. Vinson

Posting your question over and over doesn't encourage people to answer.

true... but it's a reasonable action when the Microsoft webpage is screwed up
(again), as it is currently; many users are seeing a bogus error message
saying that the message could not be posted when in fact it was. Don't blame
the OP, it's Microsoft's error (and yes, they're looking into it).
 
Top