View Full Version : Parameter Query with ORDER BY


stevecarter31
08-16-2001, 10:40 PM
I have a parameter query in Access 2000 as follows:

SELECT test.country, test.name
FROM test
ORDER BY [@Parameter]

I am prompted to input the @Parameter. However, the result is not sorted by the parameter I input (i.e. I input 'Name' or 'Country' without the quote).

Can anyone pls help me on this simple but urgent problem? Thanks a lot!!

Pat Hartman
08-17-2001, 06:46 AM
It is not possible to use parameters to supply the names of objects. You can only use parameters to supply data as in:

Select [yourParm] As AnOutputField,...

or

Where SomeField = [YourParm];

You would need to build the query in code and then run it:

Dim strSQL As String
strSQL = "SELECT test.country, test.name
FROM test
ORDER BY " & [@Parameter] & ";"

DoCmd.OpenQuery strSQL