Sort unbound list box

  • Thread starter Thread starter Harmannus
  • Start date Start date
H

Harmannus

Hallo,

I have a form with an unbound listbox with the name LArticles based on the
query qselListArticles. On that form a have a sorting option based on the
below code. The query qselListArticles also contains the below fields.

Me.Requery
Select Case Sorteren.Value
Case "1"
Forms![frmArticles].OrderBy = "tblArticles.Article"
Case "2"
Forms![frmArticles].OrderBy = "tblArticles.GroupID"
Case "3"
Forms![frmArticles].OrderBy = "tblArticles.StatusID"
End Select

How can i expand the above code with the option to sort the unbound listbox
if a case is selected?

tried

Case "1"
Forms![frmArticles].OrderBy = "tblArticles.Article"
Forms![frmArticles].LArticles.OrderBy="qselListArticles.Article"

but that doesn't work.

thanx for any tips!

Regards,

Harmannus
 
Ok, if you have an unbound list box, what is the rowsource for its data?

Is it a table/query or value list?
If it is a table/query I would modify the rowsource SQL string based upon
the user request.
If it is a value list you will first need to place the entries into an
array, sort the array, & then insert them into the list box...
 
Hallo,

Thanx for the reply.

Is use a query (I have a form with an unbound listbox with the name
LArticles based on the
query qselListArticles) named qselListArticles as source for the unbound
listbox.

I do not quite understand what you mean. How can i extend the sort i already
have (based on the tblArticle) on the form to sort the listbox?

Case "1"
Forms![frmArticles].OrderBy = "tblArticles.Article"
Forms![frmArticles].LArticles.OrderBy="qselListArticles.Article"

Doesnt work...


Regards,

Harmannus
 
I have never been a fan of the order by property as it seems less than
perfect.

You could try requerying the control itself though:
e.g.
Case "1"
Forms![frmArticles].OrderBy = "tblArticles.Article"
Forms![frmArticles].LArticles.OrderBy="qselListArticles.Article"
Me.LArticles.ReQuery
 
Back
Top