If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
IIf statement sometimes works
I have the following IIf statement on an unbound field on a form:
=IIf([Loaned/Out]="0"," ","Out of Service - Please Exit and select another Vehicle") Sometimes it comes back with the correct "Out of Service..." or nothing if the vehicle is not designated as loaned/out, but other times it comes back with "#NAME?". Why is it not consistent? Thanks. -- Donna N. |
#2
|
|||
|
|||
IIf statement sometimes works
1. If [loaned/out] is ever null you will get #name#. 2. Is [loaned/out] ever
not equal to "0"? Is "0" text or a number? If it is a number, you don't need the quotes. -- Milton Purdy ACCESS State of Arkansas "Donna" wrote: I have the following IIf statement on an unbound field on a form: =IIf([Loaned/Out]="0"," ","Out of Service - Please Exit and select another Vehicle") Sometimes it comes back with the correct "Out of Service..." or nothing if the vehicle is not designated as loaned/out, but other times it comes back with "#NAME?". Why is it not consistent? Thanks. -- Donna N. |
#3
|
|||
|
|||
IIf statement sometimes works
Golfinray:
Thanks for the info. In the table, it is a Yes/No check box. I could not get the IIf statement to work using "YES" or "NO", so I went with "0" = NO and "-1" = YES because it would then run the statement correctly when I had the check box selected. Am I assuming something that is not correct? Thanks. -- Donna N. "Donna" wrote: I have the following IIf statement on an unbound field on a form: =IIf([Loaned/Out]="0"," ","Out of Service - Please Exit and select another Vehicle") Sometimes it comes back with the correct "Out of Service..." or nothing if the vehicle is not designated as loaned/out, but other times it comes back with "#NAME?". Why is it not consistent? Thanks. -- Donna N. |
#4
|
|||
|
|||
IIf statement sometimes works
On Wed, 21 Apr 2010 07:27:01 -0700, Donna
wrote: Golfinray: Thanks for the info. In the table, it is a Yes/No check box. I could not get the IIf statement to work using "YES" or "NO", so I went with "0" = NO and "-1" = YES because it would then run the statement correctly when I had the check box selected. Am I assuming something that is not correct? A Yes/No field in a table - however it's formatted or displayed - is indeed stored as a Number, 0 for No, -1 for Yes. Comparing a -1 to a text string "Yes", or even to a text string "-1" (note the quotes!) won't give the desired result. However, there are SQL defined constants Yes and No (no quotes) which are equal to -1 and 0. In an IIF statement, remember that the first argument to IIF is an expression which evaluates to True or False. You may be able to just use the yes/no field itself: IIF([yesnofield], "value if yes", "value if no") will work and you won't need any comparison operator. -- John W. Vinson [MVP] |
Thread Tools | |
Display Modes | |
|
|