468,537 Members | 1,949 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,537 developers. It's quick & easy.

Sort listbox columns


I have just created a simple procedure that does the following:
Determines the width of the columns of a listbox.
Places a button of the correct size above each column as the form
Sorts by that column when you click the button.
Automatically toggles between ASC and DESC sort sequence.

To implement it on a new form, you simply copy the buttons from my
example on to your form, or create new ones. Then create the listbox
from a query, and name the listbox scrSortList. The OnClick event on
each button calls a function in a standard module, as does the OnOpen
event for the form: there is no code required within the form. Set
these events, and then you are done.

I have a small database with an example and instructions, which you
can get from me by sending me an email via my website
www.bluebridge.com.au. If someone wants to then post it on their
website to make it freely available, that is fine by me. I am unable
to do that myself at the moment, nor can I monitor this group for
requests either :-((.

The procedure to use it is very simple, and it prevents all that
mucking about when you change the width of the listbox columns. I
often have to select a record to filter a particular report or form,
and when users see it, they invariably ask for sort buttons. So rather
than have to resize them all the time, it now happens automatically,
and takes me about 30 seconds to set up.

Also, although it is relatively simple to put filter commands within
the buttons, as many programmers seem to do, it can be timeconsuming
and annoying when you have to do it over and over again for different
forms. Also, subsequent changes to your query / listbox can result in
errors, which seem to only become apparent when you are demonstrating
the system. With this code, the buttons don't contain any references
to the underlying fields. The function simply counts the fields in the
listbox query to know which field to sort by. Also, if the field, such
as a date, needs to appear formatted, but sorted by the raw date
order, you simply include the raw date in a zero width column,
identified by name, and Robert's your father's brother.
Nov 13 '05 #1
0 1928

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Robin Tucker | last post: by
4 posts views Thread by rn5a | last post: by
5 posts views Thread by WRH | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.