Iif statement with Nulls not working

R

Ripper

I have the following as a formula in an Access03 query:
WritingZ: IIf([Writing]=1,1,IIf([Writing]=2,1,IIf([Writing] Is Null,"",0)))

I am getting a #Error as a result in the cells with a null. What am I doing
wrong to get the #Error in only the blank cells? I get a result if I use a
number in place of the "". However I need the blanks to remain blanks.
 
M

Marshall Barton

Ripper said:
I have the following as a formula in an Access03 query:
WritingZ: IIf([Writing]=1,1,IIf([Writing]=2,1,IIf([Writing] Is Null,"",0)))

I am getting a #Error as a result in the cells with a null. What am I doing
wrong to get the #Error in only the blank cells? I get a result if I use a
number in place of the "". However I need the blanks to remain blanks.


There are no blanks in there. I think you may be having a
problem with mixing a number result and a text result. I
think(?) you might get what you want by using:

WritingZ: IIf([Writing]=1,1,IIf([Writing]=2,1,IIf([Writing]
Is Null,Null,0)))
 
R

Ripper

Worked like a charm.
--
Thanks!
Rip


Marshall Barton said:
Ripper said:
I have the following as a formula in an Access03 query:
WritingZ: IIf([Writing]=1,1,IIf([Writing]=2,1,IIf([Writing] Is Null,"",0)))

I am getting a #Error as a result in the cells with a null. What am I doing
wrong to get the #Error in only the blank cells? I get a result if I use a
number in place of the "". However I need the blanks to remain blanks.


There are no blanks in there. I think you may be having a
problem with mixing a number result and a text result. I
think(?) you might get what you want by using:

WritingZ: IIf([Writing]=1,1,IIf([Writing]=2,1,IIf([Writing]
Is Null,Null,0)))
 

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