ACC2000: Query with Expression on Expression Prompts for ParameterID: Q208968
|
When you run a query, Microsoft Access prompts you to enter a parameter value even though you have not defined a parameter in the query.
You have an expression in your query that has a critera or sort order, and the query references a different field in the query that uses an alias.
This can be seen most easily in the query's SQL view. The SELECT list can
include expression names, but other clauses, such as WHERE and ORDER BY,
cannot.
There are two ways to work around this behavior:
Microsoft Access supports referencing column aliases only in the field list (SELECT clause) of a query, not in the ORDER BY or the WHERE clause.
Field: Calc: 5*[Quantity]
Field: Total: [Calc]+20
Note that the second expression is based on the first expression.
SELECT [Order Details].Quantity, 5*[Quantity] AS Calc,
[Calc]+20 AS Total
FROM [Order Details]
ORDER BY [Calc]+20;
Note that the ORDER BY clause includes the Calc alias, which
is not supported.
Total: (5*[Quantity])+20
This change substitutes the first expression for the first expression's name in the second expression.For more information about calculated fields in queries, click Microsoft Access Help on the
Help menu, type "perform calculations in a query" in the Office Assistant or the Answer Wizard,
and then click Search to view the topics returned.
Additional query words: prb
Keywords : kbdta QryParm
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: May 13, 1999