if null or zero

S

sierralightfoot

Simple but I can't get it:
if [fielda]is null or equal to zero, then [fieldb], otherwise [fielda]
 
G

Gina Whipp

SierraLightFoot,

Is the below what you are looking for?

If(IsNull([fielda]) Or [fielda]=0,[fieldb],[fielda])

OR in a query

NameOfField: IIf(IsNull([fielda]) Or [fielda]=0,[fieldb],[fielda])

HTH,
Gina Whipp
 
S

sierralightfoot

I am using this expresion: NameOfField: IIf(IsNull([fielda]) Or
[fielda]=0,[fieldb],[fielda])
but where field is =0 I get "error' as return.

Gina Whipp said:
SierraLightFoot,

Is the below what you are looking for?

If(IsNull([fielda]) Or [fielda]=0,[fieldb],[fielda])

OR in a query

NameOfField: IIf(IsNull([fielda]) Or [fielda]=0,[fieldb],[fielda])

HTH,
Gina Whipp

sierralightfoot said:
Simple but I can't get it:
if [fielda]is null or equal to zero, then [fieldb], otherwise [fielda]
 
G

Gina Whipp

Is it a numeric field, is there a '0' in the field or is it empty (Null)? I
was going off of what you asked 'equal to zero' but if it's not a numeric
field and the field contains no zeroes then try: NameOfField:
IIf(IsNull([fielda]), [fieldb],[fielda])


sierralightfoot said:
I am using this expresion: NameOfField: IIf(IsNull([fielda]) Or
[fielda]=0,[fieldb],[fielda])
but where field is =0 I get "error' as return.

Gina Whipp said:
SierraLightFoot,

Is the below what you are looking for?

If(IsNull([fielda]) Or [fielda]=0,[fieldb],[fielda])

OR in a query

NameOfField: IIf(IsNull([fielda]) Or [fielda]=0,[fieldb],[fielda])

HTH,
Gina Whipp

sierralightfoot said:
Simple but I can't get it:
if [fielda]is null or equal to zero, then [fieldb], otherwise [fielda]
 
S

sierralightfoot

Looks right, but what is the differance in if vs iif ?
thanks

sierralightfoot said:
Looks right, but what is the differance in if vs iif

sierralightfoot said:
Simple but I can't get it:
if [fielda]is null or equal to zero, then [fieldb], otherwise [fielda]
 
G

Gina Whipp

SierraLightFoot,

Going to need one of those MVP's to explain that... All I can tell you that
'IIf' evaluates (Expression, TruePart, FalsePart) and will only return True
or False. 'If' allows conditional excecution, based on the evaluation of
the expression (such as, if... then... else).

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II


sierralightfoot said:
Looks right, but what is the differance in if vs iif ?
thanks

sierralightfoot said:
Looks right, but what is the differance in if vs iif

sierralightfoot said:
Simple but I can't get it:
if [fielda]is null or equal to zero, then [fieldb], otherwise [fielda]
 
D

David F Cox

While we wait for an MVP, IIF (arg1, arg2, arg3) is an inbuilt function
which returns a variant value.

"If" is a language element.

Gina Whipp said:
SierraLightFoot,

Going to need one of those MVP's to explain that... All I can tell you
that 'IIf' evaluates (Expression, TruePart, FalsePart) and will only
return True or False. 'If' allows conditional excecution, based on the
evaluation of the expression (such as, if... then... else).

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II


sierralightfoot said:
Looks right, but what is the differance in if vs iif ?
thanks

sierralightfoot said:
Looks right, but what is the differance in if vs iif

:

Simple but I can't get it:
if [fielda]is null or equal to zero, then [fieldb], otherwise [fielda]
 
M

Marshall Barton

Gina said:
SierraLightFoot,

Going to need one of those MVP's to explain that... All I can tell you that
'IIf' evaluates (Expression, TruePart, FalsePart) and will only return True
or False. 'If' allows conditional excecution, based on the evaluation of
the expression (such as, if... then... else).


In addition to that, the key difference is that IIf is a
**function** that only makes sense when used in an
expression. Expressions can be used in many contexts
(control source expression, calculated query fields, VBA
expressions, etc).

If is a **statement** in the VBA language that affects which
following statements are executed. It can not be used
anywhere else.
 
G

Gina Whipp

Oh dear, too late to rephrase.... Big THANKS David...

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II


David F Cox said:
While we wait for an MVP, IIF (arg1, arg2, arg3) is an inbuilt function
which returns a variant value.

"If" is a language element.

Gina Whipp said:
SierraLightFoot,

Going to need one of those MVP's to explain that... All I can tell you
that 'IIf' evaluates (Expression, TruePart, FalsePart) and will only
return True or False. 'If' allows conditional excecution, based on the
evaluation of the expression (such as, if... then... else).

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" -
Tremors II


sierralightfoot said:
Looks right, but what is the differance in if vs iif ?
thanks

:

Looks right, but what is the differance in if vs iif

:

Simple but I can't get it:
if [fielda]is null or equal to zero, then [fieldb], otherwise
[fielda]
 
Top