ASP - Sort list box <select> in VB Active X

Asked By Nevyn Campanella on 19-Jul-14 02:26 AM
I am writing in a class file.  The following code for a list box works fine. It is pulling data out of a data base.  However, what I want to do is have the data going into the list box sorted.  How do I do that?

strControls = "<BR><FORM ACTION=""htp.asp?Page=ListTopics"" "
strControls = strControls & "METHOD=""POST""><TABLE BORDER=0 "
strControls = strControls & "<p> align=""center""<select name=D1 size=8></p><BR></TD></TR>"

Do While Not rs.EOF
strControls = strControls & "<option value='" & rs("Topics") & "'>" & rs("Topics") & "</option>"

strControls = strControls & "</select></p>"
strControls = strControls & "<TR><TD ALIGN=""RIGHT""><INPUT TYPE=""Submit"" "
strControls = strControls & "VALUE=""Enter""></TD></TR></TABLE></FORM>"

What database are you using? - Asked By Robbe Morris on 07-Jun-01 01:10 PM

My guess is MS Access.

In your SQL query, you'll want to use the order by clause.
Like this:

 Dim sSQL

 sSQL = sSQL & "select MyColumnA,MyColumnB "
 sSQL = sSQL & "  from MyTable "
 sSQL = sSQL & "  Where MyColumnA = 1 "
 sSQL = sSQL & "  order by MyColumnA DESC"

 oADORec.Open sSQL

 This is just the basics.  Replace the fake column and table
 names with your own.  The Where clause should also be 
 replaced with your own conditions.  DESC and ASC are ORDER
 BY options for sort order.

Mic. Access and Thanks for the answer - Asked By Nevyn Campanella on 19-Jul-14 02:27 AM

I am using Microsoft Access 7.0
I just saw your answer below...

Sure thing... - Asked By Robbe Morris on 07-Jun-01 01:19 PM