Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIF Statement *Invalid Syntax*

Status
Not open for further replies.

shart00

Technical User
Jun 16, 2003
63
US
At the bottom is the code that I wrote but keep getting syntax errors so I thought if I broke it down, someone may have a better chance of helping:

The code needs to use the formula:
if [CC Description] = *Decherd* & [Shift(D/N)]="WE":
-(Sum([Roll])-Sum([Outside Total])-Sum([Offline Total]))/4.7375+[Authorization]

if [CC Description] = *Decherd* & [Shift(D/N)]<>"WE":
-(Sum([Roll])-Sum([Outside Total])-Sum([Offline Total]))/10.2+[Authorization]

otherwise:
if [CC Description]<>*Decherd* and [Shift(D/N)]="WE":
-(Sum([Roll])-Sum([Outside Total])-Sum([Offline Total]))/[WE Days]+[Authorization],-(Sum([Roll])-Sum([Outside Total])-Sum([Offline Total]))/[Days]+[Authorization])




Current Formula
=iif([CC Description] = *Decherd* and [Shift (D/N)]="WE",-(Sum([Roll])-Sum([Outside Total])-Sum([Offline Total]))/4.7375+[Authorization],iif([CC Description] =*Decherd and [Shift (D/N)] <> "WE",-(Sum([Roll])-Sum([Outside Total])-Sum([Offline Total]))/10.2+[Authorization], IIf([CC Description]<>*Decherd* and [Shift (D/N)]="WE",-(Sum([Roll])-Sum([Outside Total])-Sum([Offline Total]))/[WE Days]+[Authorization],-(Sum([Roll])-Sum([Outside Total])-Sum([Offline Total]))/[Days]+[Authorization])

Thank you for any and all help
 
1st, what are you trying to do with this [CC Description] = *Decherd*? do you mean
Code:
[CC Description] = "*decherd*"
 
Now the following formulas causes "wrong number arguments"

=iif([CC Description] = “*Decherd*”,iif([Shift (D/N)]=”WE”,-(Sum([Roll])-Sum([Outside Total])-Sum([Offline Total]))/4.7375+[Authorization],-(Sum([Roll])-Sum([Outside Total])-Sum([Offline Total]))/10.2+[Authorization],IIf([Shift (D/N)]="WE",-(Sum([Roll])-Sum([Outside Total])-Sum([Offline Total]))/[WE Days]+[Authorization],-(Sum([Roll])-Sum([Outside Total])-Sum([Offline Total]))/[Days]+[Authorization])))
 
Your last version was worse than your first. I think it should be something like this:

Code:
=iif([CC Description] like "*Decherd*" and [Shift (D/N)]="WE",-(Sum([Roll])-Sum([Outside Total])-Sum([Offline Total]))/4.7375+[Authorization],iif([CC Description] like "*Decherd" and [Shift (D/N)] <> "WE",-(Sum([Roll])-Sum([Outside Total])-Sum([Offline Total]))/10.2+[Authorization],IIf([CC Description] not like "*Decherd*" and [Shift (D/N)]="WE",-(Sum([Roll])-Sum([Outside Total])-Sum([Offline Total]))/[WE Days]+[Authorization],-(Sum([Roll])-Sum([Outside Total])-Sum([Offline Total]))/[Days]+[Authorization]))))
 
Works Great! Thank you! guess I needed to spell it out. Rather interesting because in 97 most of the time I did not need to be so exact. But I guess it is a learning period.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top