View Single Post
  #6  
Old May 11th, 2010, 08:47 PM posted to microsoft.public.access.forms
Bruce Rodtnick
external usenet poster
 
Posts: 16
Default How do I sort a listbox by field

And that's what I'm TRYING to do...This is what I have now:

Dim strSQL As String

strSQL = Me.lstMailTo.RowSource

strSQL = strSQL & " " & ORDER By Personnel.Email

Me!lstMailTo.RowSource = strSQL
Me!lstMailTo.Requery

***********

strSQL is picking up the proper RowSource but when I try to add the ORDER BY
to the strSQL I'm getting a two ORDER BYs in my strSQL...the old one and the
new one...and so I get NOTHING in the ListBox lstMailTo

B

"John W. Vinson" wrote in message
news
On Tue, 11 May 2010 13:25:26 -0500, "Bruce Rodtnick"

wrote:

Me!lstMailTo.RowSource.OrderBy = Email
Me!lstMailTo.OrderByOn = True
Order By Email


A listbox (unlike a Form) does not HAVE an OrderBy property.

Do as Jeff suggested: use your code to change the listbox's RowSource
property
to a SQL string which sorts as you want it.
--

John W. Vinson [MVP]