Solved

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

Posted on 2004-04-23
1
281 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
ID: 10902484
 ' 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

930 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