I recently found, while using ADO in ASP to query an Access Database, that passing request variables in the Order By clause of a SQL statement is slightly different than the WHERE clause. To pass the Order By variable along with an ASC or DESC variable, you would use the following syntax: 'This code assumes you have made your database connection.
'the following select clause uses a value from a form
'for the order by criteria and also a form value for ASC or DESC.
'You can replace the LIKE word with "=" if needed.
SQLQuery = "SELECT * FROM pcrdet WHERE PCRDescription LIKE '%" & Trim(request.form("SearchText")) & "%' ORDER BY "& request.form("SortBy") &" "& request.form("buttonSortBy")
It easy to confuse yourself by placing single and double quotes around the complete clause. Doing that will produce errors. Submitted by Bruce Strickland