Moving items in a listbox up or down

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

Guest

I want to reorder the items in a listbox by clicking on either an up or a
down arrow. I don't the first place to start with this so any help would be
greatly appreciated!

Carol
 
hi,

the only way i know how to do this is to set your preference (ascending or
descending) in the query that your form is based upon. this way everytime
you load the form the list box will automatically list the entries in
alaphabetical order either ascending or descending.

hope this helps
 
In the Click Event of your up and down arrow command buttons, put code it
that will change the RowSource property. If you are currently using a query,
you can set the sort order one way, then create an identical query that has
the sort order another way. Then in the Click event, set the RowSource to
the query that has the sort order you want. If you are using a table, you
would put code in the event to order the table. If you are using a list,
then you will have to create variables for each sort order, then set the row
source to the list you want to use.
 
Thanks for the replies guys. I guess I wasn't clear as to what I was trying
to accomplish. What I want to do is be able to select an item in the
listbox, then if I click on the up arrow, that selected item would move up in
the list box. Or conversely, if I click on the down arrow the item in the
list would be moved down one. I've found some sample code throughout the web
but it's always written in either VB.NET or C++, or C#. None of that works
in Access 2003. :-(
 
Hi Carolanne,

If the listbox's RowSource is a query, the only way to re-order the
items is to write code that changes the underlying data and/or the sort
order of the query so as to get the result you want.

If the RowSource is a value list, you need to write code that re-orders
the value list.
 
Back
Top