Changing record order through the environment

  • Thread starter Thread starter Dennis Snelgrove
  • Start date Start date
D

Dennis Snelgrove

To go off on a tangent for a moment... you know how it's possible to move
icons on the toolbars when in Customize mode? You can move them to a
different order by clicking and dragging, and the toolbar remembers what
order they should be in? Is it possible to do the same thing with a
recordset in a form? I'd like to be able to rearrange a recordset on screen
by dragging a record to another position in the list. Has anyone done this
in Access XP? If so, how? I'd really appreciate the help...

Dennis
 
I have never done this with a drag and drop, but have done it many times
using a pair of buttons labeled with up and down arrows. Behind the scenes
I used a hidden column (I called it seq) as the sort order for the rows. I
would populate this column going in, and maintain it by swapping values
around as the user pushed the up and down buttons.

Ron W
 
Hi,


It is surely possible, using an hidden field in the recordset that would
be assigned to the AbsolutePosition, "soon" when you open the form. Then,
you have to track the mouse drag and drop like movement to change the value
of the hidden field for the mean of the two records between which it is to
be inserted, then, order the recordset accordingly that famous hidden field.

The most difficult part would be the drag and drop part, since you need
to locate the ending point, in pixels, on the form, and then, compute how
many records (graphically) have been move over, by the mouse. A relative
move on the recordset clone will allow you to reach and read the implied
records. I would consult Stephen's for the mouse tracking job
(http://www.lebans.com/).


1- Keep the actual bookmark, change the mouse cursor (if appropriate)
2- Synchronize the clone : Me.RecorsetClone.Bookmark = Me.Bookmark
3- Track the mouse ending spot, compute the number of records we have
graphically completely moved over, let this value be m. Change back to the
normal mouse cursor.
4- RecordsetClone.Move m
( m negative if backward, positive if forward )
5- x=RecordsetClone.Field("HiddenField")
6- RecordsetClone.Move Sgn(m) ' move one more in the same direction
7- x=0.5*(x+ RecordsetClone.Field("HiddenField")) 'average
8- Me!HiddenField = x ' or reposition to the bookmark we saved in 1,
if necessary
9 - reorder the form



Hoping it may help,
Vanderghast, Access MVP
 
Back
Top