Why am I getting "Enter Parameter Value" when running my MS Access query?
In my query, I use the IIF
function to assign either "Before" or "After" to a field named BeforeOrAfter
using AS
.
When I run this query, however, the "Enter Parameter Value" dialog appears, requesting a value for BeforeOrAfter
. If I remove BeforeOrAfter DESC
from the ORDER BY
clause, I don't get the dialog.
Here is the offending query:
SELECT
d.Scenario,
e.Event,
IIF(d.LogTime < e.Time, 'Before','After') AS BeforeOrAfter,
d.HeartRate
FROM
Data d INNER JOIN
Events e ON d.Scenario = e.Scenario
WHERE
e.Include = Yes
ORDER BY
d.Scenario,
e.Id,
BeforeOrAfter DESC
Question: Why is my AS BeforeOrAfter
not being 开发者_高级运维recognized by the ORDER BY
clause? Why does it ask me to enter a parameter value for "BeforeOrAfter" when I run this query?
Note: I tried using brackets, single quotes, double quotes, etc., but none of that made any difference.
I beleive Access can't handle the alias feature, so you'll have to copy your IIF-block down into the Order By -clause. Or create a subquery (and then you might even find yourself forced to even not be able to use parantheses if your Access version isn't among the newest two or so).
精彩评论