IIf to evaluate a string

H

Hardworker

I am trying to evaluate a string by using an IIf function:

=IIf([WhoPaysCarriage]="Receiver",0,1)

ie if the contents of the field WhoPaysCarriage contains the word Receiver
then a 0 is returned etc
I keep getting an #error. What is wrong with the statement?
 
J

John Spencer

I am guessing you are trying to do this on a form or a report?

Do you have a control named WhoPaysCarriage? If so try changing its name to
to txtWhoPaysCarriage and see if the expression you are using works.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
H

Hardworker

That works although I'm not sure why.
Thanks a lot John



John Spencer said:
I am guessing you are trying to do this on a form or a report?

Do you have a control named WhoPaysCarriage? If so try changing its name to
to txtWhoPaysCarriage and see if the expression you are using works.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
I am trying to evaluate a string by using an IIf function:

=IIf([WhoPaysCarriage]="Receiver",0,1)

ie if the contents of the field WhoPaysCarriage contains the word Receiver
then a 0 is returned etc
I keep getting an #error. What is wrong with the statement?
 
J

John Spencer

When you have a field and a control with the same name there are situations
where Access does not know which of the two you want to use. Changing the
control name allowed Access to resolve the difficulty since there were no
longer two items with the same name.



John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 

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

Similar Threads


Top