nested If

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

Guest

My function is:
Amt:=IIF(([Contract] =99999 And [GSTYN] = -1,[Amount]/1.07,[amount]))

The result I need in this function is " If contract # is 99999 and GSTYN =
-1 (yes) then Amount is devided by 1.07 other wise the amount is not devided
by 1.07"
Contract, GSTYN and amount are names of the fileds. GSTYN is a yes/no field.

I am getting an syntax error message. What am I missing? PLease help!
 
Try remove the first "="
Amt : IIF(([Contract] =99999 And [GSTYN] = -1,[Amount]/1.07,[amount]))
 
I assume you're putting this into Access's query designer, and this is simply
a field in the query. If this is so, then change

Amt:=IIF(([Contract] =99999 And [GSTYN] = -1,[Amount]/1.07,[amount]))

to

Amt: IIF(([Contract] =99999) And ([GSTYN] = True),[Amount]/1.07,[amount])

That is, lose the equals ('='), and reapportion your parentheses. The actual
syntax error? The equals sign; it doesn't belong there.

Sam
My function is:
Amt:=IIF(([Contract] =99999 And [GSTYN] = -1,[Amount]/1.07,[amount]))

The result I need in this function is " If contract # is 99999 and GSTYN =
-1 (yes) then Amount is devided by 1.07 other wise the amount is not devided
by 1.07"
Contract, GSTYN and amount are names of the fileds. GSTYN is a yes/no field.

I am getting an syntax error message. What am I missing? PLease help!
 
You need to drop the equal sign in the beginning of the iif

Amt:IIF([Contract] =99999 And [GSTYN] = -1,[Amount]/1.07,[amount])

If the contract field type is string, then
Amt:IIF([Contract] ="99999" And [GSTYN] = -1,[Amount]/1.07,[amount])
 
My function is:
Amt:=IIF(([Contract] =99999 And [GSTYN] = -1,[Amount]/1.07,[amount]))

The result I need in this function is " If contract # is 99999 and GSTYN =
-1 (yes) then Amount is devided by 1.07 other wise the amount is not devided
by 1.07"
Contract, GSTYN and amount are names of the fileds. GSTYN is a yes/no field.

I am getting an syntax error message. What am I missing? PLease help!

1) Do not use the = sign in the query expression when creating a new
column.

2) You have an extra unneeded set of parenthesis. It isn't creating a
problem but the expression (to me anyway) is clearer without them.

Amt:IIF([Contract] =99999 And [GSTYN] = -1,[Amount]/1.07,[amount])
 
Back
Top