I'm using an Access database for a backend to an ASP.NET site and was wondering how to go about setting up and storing a parameterized query that uses a parameter to specify which field to ORDER BY. I would like the parameter to be a field name. I can't seem to get it to work properly and would appreciate an example. Below is one of the queries for which I would like to be able to do this by specifiying either Members.MemberName, DKPs, or LifetimeEarned in the ORDER BY clause.

On a similar note, if I have the following query:
Code:
SELECT Members.MemberName, Sum(DKPAudits.DKPAuditAdjPts) AS DKPs, Sum(IIf(DKPAudits.DKPAuditType=2,-DKPAudits.DKPAuditAdjPts,0)) AS PtsSpent, Sum(IIf(DKPAudits.DKPAuditType<>2,DKPAudits.DKPAuditAdjPts,0)) AS [Lifetime Earned], Count(IIf(DKPAudits.DKPAuditType=2,1,Null)) AS Epics
FROM Members INNER JOIN DKPAudits ON Members.MemberID=DKPAudits.DKPAuditMemberID
GROUP BY Members.MemberName
ORDER BY Sum(DKPAudits.DKPAuditAdjPts) DESC;
Why will it not accept "DKPs" in the ORDER BY clause when i already specify that Sum() AS DKPs above? Do I really need the same sum in the SELECT and ORDER BY clauses?