Sortable List Box?

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

I don't think this is possible, but I thought it was worth
asking.

I have a command button on a form that opens another form
with a list box. The column heads property is set
to "Yes." The list box does what I want it to do, but a
user came back with this.....

They want to be able to click on one of the column heads
and sort the list box by a different column before
choosing the value they want. Is this possile?

Thanks for any advice.
 
AFAIK, that is not possible, Don. When I click on the column header of a
list box, the first field row gets highlighted, so it appears that column
headers are simply not clickable.

What you could do is put an Option Group control on your form above the
listbox, which options such as Sort on Col1, Sort on Col2, etc. Then in
the AfterUpdate event of the Option Group, you could replace the RowSource
of the listbox depending on the selection in the Option Group.
 
Access does not do this for you, but it may be possible to use the MouseDown
or MouseUp event of the listbox.

Examine the Y to see if it the click was in the topmost row.
Examine X compared to the ColumnWidths to calculate which column was
clicked. Then change the RowSource of the list box to a SQL statement to
"ORDER BY" the relevant field.

Measurements will be in twips, where 1440 twips = 1 inch.
 
Along the same lines as Cheryl's answer, I place very
thin, captionless command buttons along the tops of my
list boxes that correspond to the visible column width
settings. I use them to call a function that alters the
ORDER BY clause of the list box's RowSource property.
 
Back
Top