Solved

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

Posted on 2004-04-23
1
280 Views
Last Modified: 2010-05-02
  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
Comment
Question by:gideonn
1 Comment
 
LVL 19

Accepted Solution

by:
Shauli earned 250 total points
Comment Utility
 ' 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now