Sorting Contents of Listbox

G

Guest

Hi,
I have 2 option groups where based on the selection of each option group, a
certain number of courses will display in the listbox. By default, the
display is sorted by Course Code. I want to add another option group of
toggle type so that I can display the listbox sorted by Course Code or Course
Number.

In other words, I have already made the selection in the earlier option
groups and the output is displayed in the listbox sorted by Course Code. I
want to add a button so that on clicking it, the contents will re-sort itself
by Course Number. Can this be done without having to resort to SELECT
statements again? Thanks.
ck
 
F

fredg

Hi,
I have 2 option groups where based on the selection of each option group, a
certain number of courses will display in the listbox. By default, the
display is sorted by Course Code. I want to add another option group of
toggle type so that I can display the listbox sorted by Course Code or Course
Number.

In other words, I have already made the selection in the earlier option
groups and the output is displayed in the listbox sorted by Course Code. I
want to add a button so that on clicking it, the contents will re-sort itself
by Course Number. Can this be done without having to resort to SELECT
statements again? Thanks.
ck

You'll have to use a different Select statement in the rowsource of
the list box each time you wish to re-sort.

Add a toggle button (caption "CourseCode" to the form:

If Me!ToggleName.Caption = "CourseCode" then Then
ListBoxName.Rowsource = "Select TableName.* from TableName Order
By TableName.CourseCode;"
Me!ToggleName.Caption = "CourseNumber"
Else
ListBoxName.Rowsource = "Select TableName.* from TableName Order
By TableName.CourseNumber;"
Me!ToggleName.Caption = "CourseCode"
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top