Move Up, Move Down Effect

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi again,

By any chance does anybody know where I could find help (or if he could help
me) in creating a move up, move down effect? I mean the facility that can be
found next to listboxes giving someone the ability to move listbox items
higher or lower in the relative order they appear in the listbox

thanks in advance, george
 
Hi George

This depends on the type of your RowSource. If it is a "Table/Query", then
you must change the values in the "order by" field of the underlying table
so that the records are sorted in the new order.

If it is a "Value List", then you must change the order of the elements in
the RowSource string. For example, if your list is:
aaaa
bbbb
cccc
dddd
then the RowSource is:
"aaaa;bbbb;cccc;dddd"

If the currently selected row is "cccc", and you click the UP button, then
you must change the RowSource to:
"aaaa;cccc;bbbb;dddd"

You can do this by manipulating the strings, but if you have Access 2002 or
later then the following event procedures for your up/down buttons should do
the trick:

Private Sub cmdUp_Click()
Dim i As Long, sItem As String
With lstItems
i = .ListIndex
If i > 0 Then
sItem = .Value
.RemoveItem .ListIndex
.AddItem sItem, i - 1
End If
End With
End Sub

Private Sub cmdDown_Click()
Dim i As Long, sItem As String
With lstItems
i = .ListIndex
If i >= 0 And i < .ListCount - 1 Then
sItem = .Value
.RemoveItem .ListIndex
.AddItem sItem, i + 1
End If
End With
End Sub
 
I build 2 recordsets. I use one to find the values from the item being
replaced and store those columns in a set of variables. Then I update the
first recordset with the second. Then I write the variables to the second
recordset.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Back
Top