IIF Statement using Is Null and is Not Null

G

Guest

BothFields: IIf([Remainingshares]="is
null",[Buysellshrs],IIf([Remainingshares]="is not null",[RemainingShares]))


What I am trying to do is

If Remaining Shares are BLANK show BUYSELLSHRS

If Remaining Shares are NOT BLANK Show Remaining shares
 
B

BruceM

There are a few difficulties here. There are only two possibilities for
[RemainingShares]: either it is blank or it is not. You don't need the
second IIf for just two possibilities. An IIf statement can be thought of
thus: If a condition is true, do something, otherwise do something else.
Another thing is that you are checking for the text "is null" and "is not
null". That's what the quotes are for. But you want to check whether the
field is blank.
With that in mind, the following may work.
BothFields: IIf([Remainingshares] is null,[Buysellshrs],[RemainingShares])
The other thing that needs mentioning is that Null is not the same as an
empty (zero-length) string, nor is it the same as 0. Is Null will not
necessarily produce the desired results. Instead of Is Null you could use =
"" or = 0, depending on what is actually in the Remainingshares field.
 
G

Guest

Thank you
That work great.

BruceM said:
There are a few difficulties here. There are only two possibilities for
[RemainingShares]: either it is blank or it is not. You don't need the
second IIf for just two possibilities. An IIf statement can be thought of
thus: If a condition is true, do something, otherwise do something else.
Another thing is that you are checking for the text "is null" and "is not
null". That's what the quotes are for. But you want to check whether the
field is blank.
With that in mind, the following may work.
BothFields: IIf([Remainingshares] is null,[Buysellshrs],[RemainingShares])
The other thing that needs mentioning is that Null is not the same as an
empty (zero-length) string, nor is it the same as 0. Is Null will not
necessarily produce the desired results. Instead of Is Null you could use =
"" or = 0, depending on what is actually in the Remainingshares field.

Crazyhorse said:
BothFields: IIf([Remainingshares]="is
null",[Buysellshrs],IIf([Remainingshares]="is not
null",[RemainingShares]))


What I am trying to do is

If Remaining Shares are BLANK show BUYSELLSHRS

If Remaining Shares are NOT BLANK Show Remaining shares
 
B

BruceM

You're very welcome.

Crazyhorse said:
Thank you
That work great.

BruceM said:
There are a few difficulties here. There are only two possibilities for
[RemainingShares]: either it is blank or it is not. You don't need the
second IIf for just two possibilities. An IIf statement can be thought
of
thus: If a condition is true, do something, otherwise do something else.
Another thing is that you are checking for the text "is null" and "is not
null". That's what the quotes are for. But you want to check whether
the
field is blank.
With that in mind, the following may work.
BothFields: IIf([Remainingshares] is
null,[Buysellshrs],[RemainingShares])
The other thing that needs mentioning is that Null is not the same as an
empty (zero-length) string, nor is it the same as 0. Is Null will not
necessarily produce the desired results. Instead of Is Null you could
use =
"" or = 0, depending on what is actually in the Remainingshares field.

Crazyhorse said:
BothFields: IIf([Remainingshares]="is
null",[Buysellshrs],IIf([Remainingshares]="is not
null",[RemainingShares]))


What I am trying to do is

If Remaining Shares are BLANK show BUYSELLSHRS

If Remaining Shares are NOT BLANK Show Remaining shares
 

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