Displaying text in alphabetical order

Results 1 to 3 of 3

Thread: Displaying text in alphabetical order

  1. #1
    Join Date
    Dec 1969
    Posts
    167

    Default Displaying text in alphabetical order

    Hi gang, The data in my Access file is setup in alphabetical order (Descending down, A - Z). When I display on a page.. using the following.. It comes out in random order.<BR><BR>&#060;%<BR>Set Conn = Server.CreateObject("ADODB.Connection")<BR>Conn.Op en "phonebook"<BR>sql = "SELECT lastname, firstname FROM convergenet WHERE lastname LIKE &#039D%&#039" <BR>Set RS = Conn.Execute(sql)<BR>&#037;&#062;<BR><BR>&#060;tab le border="1"><BR><BR>&#060;% Do While not RS.eof&#037;&#062;<BR> &#060;TR><BR> &#060;TD>&#060;b>&#060;%=rs.fields("lastname") &#037;&#062;&#060;/b>&#060;/TD><BR> &#060;TD>&#060;% = RS("firstname") &#037;&#062;&#060;/TD><BR> &#060;/TR><BR> &#060;% <BR> RS.MoveNext<BR> Loop<BR> &#037;&#062;<BR>&#060;/table><BR><BR>This displays the D&#039s in a weird order.. not A - Z, nor Z - A.. but in what seems a random order yet it doesn&#039t not display them in a new order each time you refresh.<BR><BR>What am I doing wrong? Can someone help?<BR><BR> - Don

  2. #2
    Michael Lindley Guest

    Default RE: Displaying text in alphabetical order

    You can use the ORDER BY statement to get it to go in specific order. Your SQL statement would look like this to order by the lastname. (You can do this by numbers, dates, etc.. as well):<BR><BR>sql = "SELECT lastname, firstname FROM convergenet WHERE lastname LIKE &#039D%&#039 ORDER BY lastname;"<BR><BR>You can also do it in reverse by using the desc option of the ORDER BY Statement like this:<BR><BR>sql = "SELECT lastname, firstname FROM convergenet WHERE lastname LIKE &#039D%&#039 ORDER BY lastname DESC;"

  3. #3
    Join Date
    Dec 1969
    Posts
    167

    Default RE: Displaying text in alphabetical order (Thanks!!!)

    I appericate the help. I almost had it.<BR><BR> - Don

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •