Sort unbound list box

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
 
J

James Goodman

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...
 
H

Harmannus

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
 
J

James Goodman

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
 

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