Re-sort a table by user-selected variable

I'm using an Access 2000 db as the data source for a table on a web page that's generated with ASP.

The table looks like:

Project Name       Coordinator      Product
Project X             Kitty                  Rule
Project Me           Bear                 Rule
Nuke 'Em            Kitty                   Lawsuit

When the page appears the first time, the projects are sorted by project name.
I'd like to be able to allow the user to click on the column heading (which is also the field name) to re-sort the output by that field.

I've been trying to get this to work by setting the column names up as:

<a href=showprojects.asp?pickorder=Coordinator>Coordinator</a>

thinking that a click on that link should set the variable pickorder equal to the desired field name.

The asp code then says:

pickorder=request("pickorder")
strsql="SELECT * from tblProjects ORDER BY '" & pickorder & "'"

When I click on a link, the URL indicates "it" understands that pickorder is equal to Coordinator but it doesn't re-sort the data.

What am I doing wrong?

If you need more code, just ask.  I'm a newbie so I don't know when enough is too much and I thought I'd spared you digging through a bunch of irrelevant stuff.

Thanks in advance.

Kitty
LVL 1
prettykittyqAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fritz_the_blankCommented:
What happens if you do this right after:

pickorder=request("pickorder")
strsql="SELECT * from tblProjects ORDER BY '" & pickorder & "'"
response.write strsql

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
prettykittyqAuthor Commented:
Trying it out.  Be right back.

Kitty
0
prettykittyqAuthor Commented:
I get a line at the top of the page that says:

SELECT * from tblProjects ORDER BY 'ProjectName'

Should I not have put the single quotes in there?
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

prettykittyqAuthor Commented:
Fritz, you are brilliant!

I got rid of the single quotes and it now works.

Thanks a whole bunch.  That was driving me crazy.

Cheers!

Kitty
0
fritz_the_blankCommented:
Glad to have helped.

Whenever things don't work the way that you expect, use a response.write followed by a response.end to figure out what is happening.

Good luck with your project,

FtB
0
fritz_the_blankCommented:
As an aside, you need the delimiters for where something ='something' when that something is text or date. You also need it for insert clauses for text and date values, but not for order by clauses.

FtB
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.