?
Solved

Re-sort a table by user-selected variable

Posted on 2004-11-20
6
Medium Priority
?
239 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:prettykittyq
  • 3
  • 3
6 Comments
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 2000 total points
ID: 12635992
What happens if you do this right after:

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

0
 
LVL 1

Author Comment

by:prettykittyq
ID: 12636011
Trying it out.  Be right back.

Kitty
0
 
LVL 1

Author Comment

by:prettykittyq
ID: 12636018
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:prettykittyq
ID: 12636023
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12636041
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12636045
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question