Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

Sorting a combo box that doesn't have a "Sort" property

  Below is my INI sub that fills all of the various objects on my form.  I fill a combo box on this form from a table in a database as shown...  However, the combo box always is out of order even thought the table is alphabetical....  Can anyone help me?!?  Thanks!


----------  CODE ----------
    ' Assigns default values to variables
    strReportTable = "SupervisorQuery_tbl"
       
    ' Opens a connection to CACS Dollars Database
    conCACS.Open "Provider=microsoft.jet.oledb.4.0;" + _
       "Data Source=" & GetPath & "FS Admin.mdb"
   
    ' Opens table from database
    recCACS.Open strReportTable, conCACS, adOpenKeyset, adLockOptimistic
   
    Do Until recCACS.EOF
        With recCACS
             
           ' Get CustName and Location Code
           SupNameCB.AddItem !LASTNAME & ", " & !FirstName
           
         .MoveNext
        End With
    Loop
     
    ' Closes table and database connections
    recCACS.Close: conCACS.Close
---------  BREAK --------
0
gideonn
Asked:
gideonn
1 Solution
 
ShauliCommented:
 ' Assigns default values to variables
    strReportTable = "SELECT * FROM SupervisorQuery_tbl ORDER BY LASTNAME asc;" '<<<<<<<<<<<<<<<<<
       
    ' Opens a connection to CACS Dollars Database
    conCACS.Open "Provider=microsoft.jet.oledb.4.0;" + _
       "Data Source=" & GetPath & "FS Admin.mdb"
   
    ' Opens table from database
    recCACS.Open strReportTable, conCACS, adOpenKeyset, adLockOptimistic
   
        With recCACS
             Do Until .EOF
                 ' Get CustName and Location Code
                 SupNameCB.AddItem !LASTNAME & ", " & !FirstName
           
                  .MoveNext
             Loop
        End With

     
    ' Closes table and database connections
    recCACS.Close: conCACS.Close


0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now