Why am I getting "Enter Parameter Value" when running my MS Access query?
        Posted  
        
            by DanM
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by DanM
        
        
        
        Published on 2010-03-18T19:26:00Z
        Indexed on 
            2010/03/18
            19:31 UTC
        
        
        Read the original article
        Hit count: 361
        
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.
© Stack Overflow or respective owner