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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sum(Iif) in a query problem

Status
Not open for further replies.

cookie5

Programmer
Jan 19, 2003
47
US
I have a query that works fine until I put the following statement in the sql:

Sum(Iif(SBL =1,([Totalreg Labor]+[Totalot Labor]/2), ([Totalreg Labor]+[Totalot Labor])) AS [Total Labor],

The error I get is "Syntax error(missing operator) in query expression."
When clicking ok it highlights the AS

The above sql is in the select portion of the query and is to see if a checkbox is checked, if it is then it should total totalreg labor and totalot labor and divide the sum by 2, if it is not true then just add totalreg labor and totalot labor, regardless of true or false, put the sum in the calculated field total labor.

What am I missing? Any help will be appreciated.
 
You should take the time to count the left and right parens. You should have the same number of each.

Do you really want to divide the Totalot Labor by 2 and then add this to the Totalreg Labor?

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
What about this ?
Sum(([Totalreg Labor]+[Totalot Labor])/IIf(SBL,2,1)) AS [Total Labor],

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV,
You have done it again! Thanks, I had not thought of putting the IIF at the end. THANK YOU
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top