Click to See Complete Forum and Search --> : re-order the table records based on that new value


malbar99
07-06-2004, 12:58 AM
Hi,
I have a web page (ASP) where the user can change the value of order field while update the record.
I want the access table accept the user input and re-order the table records based on that new value.

Can I do that (I'm using access 2003)?

buntine
07-06-2004, 01:04 AM
Yes, you need to use the ORDER BY SQL clause.

SELECT * FROM tableName ORDER BY fieldName DESC

DESC will order the records in descending order. You can also use ASC, which will order the record in ascending order (lowest to highest).

You can incorporate a field name into the SQL query using the QueryString collection.

' The URL is: page.asp?order=SomeField

SqlQuery = "SELECT * FROM TableName ORDER BY " & Request.QueryString("order") & " DESC"


Regards,
Andrew Buntine.

malbar99
07-06-2004, 06:42 AM
That is if I want to change the browseing data.

What I need is to change the order in tha table.

buntine
07-06-2004, 07:16 AM
Oh, i think i know what you mean now.

To actually reorder every record in the table, you would most likely have to extract them all, order them accordingly, and then re-insert them.

To my knowledge, there is no built-in function, which will actually reorder your records within a table.

I would just write a script to order the records dynamically as they are extracted.

Regards,
Andrew Buntine.