views:

308

answers:

4

Keep getting this error after inserting a subdatasheet into a query and trying to show it by clicking on the +

Column (Cost) was used in a CALC expression but is not defined in the rowset.

What is confusing, is that there isn't even a column named 'Cost' anywhere in the database. Although there is a column that starts with 'Cost' and has spaces in. Setting that to an alias without spaces does not fix the problem

A: 

when you have space in a column name you need to put brackets around it in sql server

[Cost ]

SQLMenace
The subdatasheet is added in Access, not SQL. I tried brackets, but then it just says "Invalid column name '[Cost With Spaces]'"
Sam
A: 

There's always making a solution that doesn't use a subdatasheet. Although the subdatasheet tool isn't loathed as universally as the "look-up field," it's at least similar in that it trades straight-forward table handling for a kind of convenience that can be costly. So I'd try building it without the subdatasheet, and see what happens.

Smandoli
Sam, you commented that "The query cascades down ... The subdatasheet is a query, with further subdatasheets..." Using a subdatasheet is never required; and if you haven't solved the problem, it would seem that not using subdatasheets is the obvious next step.
Smandoli
A: 

Try creating a query based upon the table that you subdatasheet is referencing, and then reference the query instead.

CodeSlave
The query cascades down, e.g. summary -> balances -> transactions. The subdatasheet is a query, with further subdatasheets and works properly. It it the top level one (which is an aggregate query) that fails to work. It worked when it was Access (MDB), but doesn't with a SQL backend (i.e ADP)
Sam
A: 

Not sure why, but it was related to a sort in one of the subqueries, even though there is no column called 'Cost' being sorted. Once I removed sorting, it worked.

Sam