My first example, and the basis for the post, doesn't include any sort
interaction. It is simply changing the underlying query that chokes
Access.
I understand the point you are making and thought it might be a place
to
start to look for the answer. note: hard to believe that would be by
design...if I wanted the sort to stick I would have put it in the SQL.
I
left it OUT of the SQL specifically, yet Access wants to put it in just
because I sorted the results table...amazing.
:
Hi.
Did you leave out something in your steps to reproduce?
<vbg> I know what he did!
After running the query, he sorted on the column "Expr1001," then went
back
to SQL View, changed the SQL to use an alias, then ran the query
again.
Since the column name no longer exists, Jet asked for it because the
QueryDef's OrderBy Property was set on this column.
To fix it, open the query in Design View, right-click on the query
diagram
and select "Properties" from the pop-up menu. Delete Expr1001 from
the
Order By Property, then close the Properties dialog window and save
the
query.
This behavior is by design, because users can set the sort order by
SQL
statement, by the "Sort" field in the query grid, or merely selecting
the
column, then pressing the "Sort Ascending" (or Descending) button on
the
toolbar.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address, so that a
message
will be forwarded to me.)
Beware to those who use munged addresses: known newsgroup E-mail
harvesters
for spammers are
[email protected] and
[email protected]
- - -
When you see correct answers to your question posted in Microsoft's
Online
Community, please sign in to the Community and mark these posts as
"Answers," so that all may benefit by filtering on "Answered
questions"
and
quickly finding the right answers to similar questions. Remember that
the
first and best answers are often given to those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
in
message "Dirk Goldgar" wrote:
in
message Why does Access remember column headers from a query result, then
ask me to provide a value for that column before it will run the
query?
Here is an example that I can reproduce at will....
This query: SELECT smf30.Job, Sum(smf30.CPU) produces a table
with 2
columns, one named Job and the other column header is Access
generated, Expr1001.
That's can't be the actual query; it's not a valid query, since
there's no GROUP BY clause. Please post the SQL of the actual
query
you're starting with. Are you building, modifying, and testing
these queries in Query Design View?
==That was the operative part of the query for the question, here
is
the whole query, not sure why it matters:
SELECT job, sum(cpu) AS [Net CPU]
FROM smf30
WHERE type in (2,3)
GROUP BY job
HAVING sum(cpu) > 500
ORDER BY job DESC;
change the query to add an 'AS' clause: SELECT smf30.Job,
Sum(smf30.CPU) AS [Net CPU] and run the query. Access throws up
a
text box and says Enter Parameter Value queryx.Ecpr1001
How are you running this query? Is it the recordsource of a form,
the rowsource of a combo box, just opened as a datasheet from the
Queries tab of the database window, or what?
Run from the SQL editing window with the exclamation point (!)
Unbelievable.
What could one possibly enter as a meaningful value for the
RESULTS
table BEFORE the query even runs?
The only way to get Access to 'forget' that original column (with
the "AS" clause) is to reboot the machine, closing Access and
bringing it back up will not solve it.
Anybody have ANY idea what the heck is going on here?
I need more info about what you have actually done. Can you give
me
simple steps to reproduce the error?
Yep.
Type the above query, (or like version based on your data) without
the "AS" clause.
Get the results table with Expr1001 as the header for the SUM
funciton
results.
Edit the query and add the "AS [Net CPU]" clause. Hit the
exclamation
point, and Access asks for the value of yourqueryname.Expr001
Thanks for your help
Hmm, it didn't do that for me, using Access 2002. Here's what I
did:
1. Create new query in design view.
2. Switch to SQL view.
3. Enter:
SELECT tblData.BaseName, Sum(tblData.intNumber)
FROM tblData
GROUP BY tblData.BaseName
HAVING Sum(tblData.intNumber)>1;
4. Run it. Column header is the generated name "Expr1001".
5. Switch back to SQL view.
6. Edit SQL, making it like this:
SELECT tblData.BaseName, Sum(tblData.intNumber) AS MySum
FROM tblData
GROUP BY tblData.BaseName
HAVING Sum(tblData.intNumber)>1;
7. Run it. No parameter prompt appears. Column header is "MySum".
Did you leave out something in your steps to reproduce?
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)