You tried to execute a query that doesn't include the specified expression as part of an aggregate function

Heres the query

Price Each USD: IIf(Left([mc476mth]![plant],2)="BR",([mm60]![price]/[Forms].[main]![brl to usd]),IIf(Left([mc476mth]![plant],2)="CA",([mm60]![price]/[Forms].[main]![cad to usd]),IIf(IsNull([mc476mth]![plant]),"N/A")))

What's wrong w/ this?  Even if I change it to a "GROUP BY" it still gives me the same error.
akh7025Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nico5038Commented:
Try:

[Price Each USD]: IIf(Left([mc476mth]![plant],2)="BR",([mm60]![price]/[Forms].[main]![brl to usd]),IIf(Left([mc476mth]![plant],2)="CA",([mm60]![price]/[Forms].[main]![cad to usd]),IIf(IsNull([mc476mth]![plant]),"N/A")))

The [ and ] is needed for the spaces, better never to use spaces in fieldnames...

Nic;o)
0
Data-ManCOOCommented:
Can you post the whole SQL Statement?

Thanks,
Mike
0
Steve BinkCommented:
When you create a query using a GROUP BY clause, each field listed MUST be:

a) Also listed in the GROUP BY clause, or
b) part of an aggregate function.

For example, this query will return exactly the same error:

SELECT F1, F2 FROM MyTable GROUP BY F1

To make the query work, you could do one of two changes:

a) SELECT F1, F2 FROM MyTable GROUP BY F1, F2
b) SELECT F1, Count(F2) FROM MyTable GROUP BY F1

You can find a list of acceptable aggregate functions by search Access help for "aggregate function".  Two examples are SUM and COUNT.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shanesuebsahakarnCommented:
You could wrap the whole thing up in a function such as First. For example:

Price Each USD: First(IIf(Left([mc476mth]![plant],2)="BR",([mm60]![price]/[Forms].[main]![brl to usd]),IIf(Left([mc476mth]![plant],2)="CA",([mm60]![price]/[Forms].[main]![cad to usd]),IIf(IsNull([mc476mth]![plant]),"N/A"))))

and change the group by to "Expression". Without looking at your SQL though, I suspect one of the comments posted by others above will be closer to the mark.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.