I know there has to be a fairly simple way to do this.
- I load a listbox from a database table, storing a “ORDER” field in rowtag
- The user has the ability to drag the rows into a desired order
- How can I easily determine which rowtags need to be altered…
Not just the rowtag, but the minimum amount of SQL to update the table itself
MsgBox str(newPosition) + EndOfLine + str(me.ListIndex)
What do you want to do to the table?
Write an order by column back to it?
You need to hold the ID and original order somewhere.
rowtag = theuniqueID
celltag(row,0) = the orderby value
loop through the listbox.
Any where the listindex doesn’t agree with the celltag:
update table set orderby = celltag where id = rowtag
…if I havent misunderstood…
I was hoping for something… more along
update table set seq=newposition+1 where seq=oldpostion
update table set seq=seq+1 where seq>newposition
I THINK this will work … but only if moving an item UP in the sequence
but I’m thinking you idea is “safer”… since not only can the user drag the order, but they can drop new records as well, and those new records have to derive they sequence position from the current “listindex” (ie. insert after)
How to distingush between… “DRAG” and “Multiple Select”
I need to select one or more records in Listbox 1 to drag to Listbox 2
But if I click a row, and move the mouse… it starts selecting rows, NOT dragging the single row…
and if I select multiple rows, and try to drag. it unselects all but the last row