By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,142 Members | 1,850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,142 IT Pros & Developers. It's quick & easy.

Sort listbox columns

P: n/a
Ray
Folks,

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
opens.
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.