IIf statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following statement and keep getting "YES" where I should be
getting "WAIVED" or "NO". Does anyone know why, everything else evaluates
correctly.

acfee: IIf([admit_dec_code] Is Null Or
[admit_dec_code]="R","",IIf([admit_dec_code] Is Not Null Or
[admit_dec_code]<>"R" And [date_acc_fee_paid] Is Not
Null,"YES",IIf([admit_dec_code] Is Not Null Or [admit_dec_code]<>"R" And
[date_acc_fee_paid] Is Null And [accept_fee_amount]="1","WAIVED","NO")))
 
didn't work.

Jon Lewis said:
Try:

IIF(IsNull(YourExpression)....
&
IIF(Not IsNull(YourExpression)....

HTH

Mike said:
I have the following statement and keep getting "YES" where I should be
getting "WAIVED" or "NO". Does anyone know why, everything else evaluates
correctly.

acfee: IIf([admit_dec_code] Is Null Or
[admit_dec_code]="R","",IIf([admit_dec_code] Is Not Null Or
[admit_dec_code]<>"R" And [date_acc_fee_paid] Is Not
Null,"YES",IIf([admit_dec_code] Is Not Null Or [admit_dec_code]<>"R" And
[date_acc_fee_paid] Is Null And [accept_fee_amount]="1","WAIVED","NO")))
 
Mike: Looks like you might be missimg some required parens around the OR
components when they are combined with AND logic. Try the code below. I did
shorten the field names for conciseness, so you'll have to blow those back
up. I ran a quick test and your way did indeed return Yes or Null. With the
parens, all choices appear to be correct. Let me know if this solves your
problem.

IIf([ADC] Is Null Or [ADC]="R","",IIf(([ADC] Is Not Null Or [ADC]<>"R") And
[DAFP] Is Not Null,"YES",IIf(([ADC] Is Not Null Or [ADC]<>"R") And [DAFP] Is
Null And [AFA]="1","WAIVED","NO")))

Actually, when I attack logic with three levels of IIF statements, I tend to
create a Function so I can make the logic more visible to my old eyes.
 

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

Back
Top