If...Elseif...Else

  • Thread starter Thread starter Shri
  • Start date Start date
S

Shri

Hi All,

I have a field in query design that checks for If...Elseif...Else. Below is
the field. I am having the issue with the field. I get syntax error. I
really can't figure out what is the error in the field. Can anyone please
please help me with this.

*****
Points_Possible: IIf((([appeal_type]="Audit the Auditor") Or
([appeal_type]="Appeal" And Not [appeal_var]="Data Entry") Or
([appeal_type]="Internal Review" And Not [appeal_var]="Data Entry") Or
([appeal_type]="Non UW Review" And Not [appeal_var]="Data
Entry"),100),IIf((([appeal_type]="Appeal" Or [appeal_type]="Internal Review"
Or [appeal_type]="Non UW Review") And [appeal_result]="Upheld" And
[appeal_rcause]="20/20 Bump"),20),Null)

*****

Thanks in advance.
 
UNTESTED --
Points_Possible: IIf((([appeal_type]="Audit the Auditor") Or
([appeal_type]= "Appeal" And [appeal_var]<>"Data Entry") Or ([appeal_type]=
"Internal Review" And [appeal_var]<>"Data Entry") Or ([appeal_type]="Non UW
Review" And [appeal_var]<>"Data Entry"), 100),IIf((([appeal_type]="Appeal" Or
[appeal_type]="Internal Review" Or [appeal_type]="Non UW Review") And
[appeal_result]="Upheld" And [appeal_rcause] ="20/20 Bump"),20),"")
 
I think you have a couple of misplaced ")" characters. move the ) that
follow the ,100) and ,20) so that they preceed the commas, like:

), 100
and
), 20

When I have complicated or nested IIF( ) statements, I will frequently just
write a function and pass in all the values that are needed to the function.
Then I can write code that is much easier to read.

Additionally, one of the things about using the IIF( ) expression is that it
will evaluate all of the expressions in it before it returns a result, so if
one of the expressions in the statement evaluates to an error, you will get
an error. As an example, try the following in the debug/immediate window.

?iif(true, 100, iif(50/0 > 0, 10, 20))

Even though the first test evaluates to true, the nested IIF( ) in the False
portion of the expression gets evaluated and generates a divided by zero
error. By using a function, you can test for expressions that will generate
errors and provide an appropriate response when an error is encountered.

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
Back
Top