iif won't return value

  • Thread starter Thread starter Irene
  • Start date Start date
I

Irene

Guest
I am trying to do a conditional display in a report. I have simplified it to:

IIf (1,"",[textvar])

that works fine. If I change "1" to "0", I don't get the value of textvar returned, but get "#Error".
Anybody know why?
Thanks
 
You seem to be missing the full conditional expression, as in
Iif([Field] = 1,"",[textvar])
or
Iif([Field].Value = 1,"",[textvar])
 
Thanks, but that's not the problem.
if I do

IIF (1,"","123") I get the empty string, but if I do
IIF (0,"","123") I get "123"

the problem seems to be only when it should return [textvar].
I'm doing it this way only as a test before I add the real conditional.




[This message has been edited by Irene (edited 04-26-2000).]
 
I may be wrong, but I think if you add the real conditional you'll find the expression works. Without an explicit a field or variable, Access is taking whatever variable is open and evaluating it. At least you seem to have gottenr id of your error message.
 
Sorry, that doesn't help. I am sure the problem is not in the control part, but in the return of a variable.
 
Where are you using this expression? I've tested the same expressions several times, and it always works if there is a condition to evaluate. For example, I have a report with two fields, Score and Placement. Score has a control source of the score field in a table, and Placement is unbound. In the Control Source for Placement I put =Iif([Score]<50,"Under 50","50 or Over"). This expression evaluates the number in the field score and returns one of the 2 choices in the field Placement. It should work for you if you are correctly referring to the field to be evaluated.
 
Irene, Axis is correct. You have not specified a valid condition statement. What do you think "If 0" means - what does "If 1" mean? The test doesn't make any sense. Access is interpreting the condition as - "If 0 is true" or "If 1 is true". As it happens 0 is always false so the false path will always be taken and 1 is always true so the true path will always be taken. Neither test will ever produce a different result so neither could ever be used to toggle a conditional display since that implies that sometimes the condition should return true and sometimes it should return false.
 

Users who are viewing this thread

Back
Top Bottom