Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Sort Order for a table that user can update

Status
Not open for further replies.

scriggs

IS-IT--Management
Jun 1, 2004
286
GB
I have a table with a list of names.

I need to setup a custom sort order that the user can set and change at will. Any ideas...
 
Ive just realised Im not clear - there is no actual sort order, something like

Turnover
Cost of Sales
Gross Profit

If I use a sort order these will not appear correctly. At the moment I have a numeric field next to the narrative

1 Turnover
2 Cost of Sales
3 Gross PRofit

But I want to allow a user to insert new fields - how can I automatically get the sort order to work itself out?
 
assign your sort sequence numbers in increments of 100

100 Turnover
200 Cost of Sales
300 Gross PRofit

then the user can insert new items wherever desired, using some convenient number "in between" the sequence numbers where the new item is supposed to sort

100 Turnover
200 Cost of Sales
300 Gross PRofit
150 Depreciation

rudy | r937.com | Ask the Expert | Premium SQL Articles
SQL for Database-Driven Web Sites (next course starts May 8 2005)
 
Thanks, thats a good idea. Any idea how to automate it fully though?
 
The basic idea would be to ask the user where the new entry should fit and then calculate the average of the previous and next entry.

You'll need extra code to cope with:
Adding the new entry before all existing entries
Adding the new entry after all existing entries

And you would have to deal with the case where you've used up all the numbers and there's no space left between 142 and 143.

Perhaps you should renumber after each insertion so that the number always go up in tens.


Geoff Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top