Solved

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

Posted on 2004-04-23
1
282 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Access - Capture pressed key onclick 4 42
Cannot Load VB6 on Windows 10. Installed OK but error on opening existing project. 7 99
Using "ScreenUpdating" 6 73
MsgBox 4 69
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

820 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