iif statement

R

Rover

I have a form that has a record source of table_a. In that table is
field VoidM which is a one character text field. If the value is "0"
(zero) I want the form to display "X" else "Y".

This statement gives me #error
=IIf([VoidM]="0","X","Y")


This statement always displays "X".
=IIf([VoidM],"X","Y")

Any ideas would be appreciated.

Tia
Jim
 
D

Dirk Goldgar

Rover said:
I have a form that has a record source of table_a. In that table is
field VoidM which is a one character text field. If the value is "0"
(zero) I want the form to display "X" else "Y".

This statement gives me #error
=IIf([VoidM]="0","X","Y")


This statement always displays "X".
=IIf([VoidM],"X","Y")

Any ideas would be appreciated.

Tia
Jim

I see no reason why the details you describe should give an error.
Please verify that the field [VoidM] is really of type Text. Am I right
in thinking your IIf expression is in the controlsource of a text box?
Have you really reduced the form and controlsource to this simple level
and tested it, or ave you just simplified it in this message?
 
F

fredg

I have a form that has a record source of table_a. In that table is
field VoidM which is a one character text field. If the value is "0"
(zero) I want the form to display "X" else "Y".

This statement gives me #error
=IIf([VoidM]="0","X","Y")

This statement always displays "X".
=IIf([VoidM],"X","Y")

Any ideas would be appreciated.

Tia
Jim

In addition to what Dirk has written, make sure the name of the
control is NOT "VoidM".
 
R

Rover

I think ht problem was that indeed the control was voidM. I put the
code in an unbound text box and it worked fine.

Thanks for the help

Jim
 

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