Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-10-29
6
Medium Priority
?
308 Views
Last Modified: 2012-06-22
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.
0
Comment
Question by:akh7025
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 54

Expert Comment

by:nico5038
ID: 12445950
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
 
LVL 18

Expert Comment

by:Data-Man
ID: 12445980
Can you post the whole SQL Statement?

Thanks,
Mike
0
 
LVL 51

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 12446240
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
 
LVL 41

Assisted Solution

by:shanesuebsahakarn
shanesuebsahakarn earned 500 total points
ID: 12446599
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question