Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel 2003 - sort ComboBox, list of data from access 1

Status
Not open for further replies.

Pcfred

Technical User
Jan 15, 2002
54
US
Currently I'm populating a combobox in excel from a access database. I need to sort the data in the combobox to display in alpha order and the access database is in order of automatic record ID. Can this be done w/o putting the data on a worksheet and then sorting?
 



Hi,

"I'm populating a combobox in excel from a access database"

using what method?

If a query, why not sort the resultset?

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Basically it runs throught the whole database and populates the Excel combobox with any row that the contains the TextBoxCust value in the 'BU' column of the database. The database is not mine to manipulate or add queries to.

Thanks for the help guys.

Here's the portion that fills the combobox.

rsMain.MoveFirst
Do Until rsMain.EOF
If rsMain.Fields("BU") = Me.TextBoxCust Then


LoadFrm.ComboBoxAssembly.AddItem
LoadFrm.ComboBoxAssembly.list(i, 0) = rsMain.Fields("1Assy") & " Rev: " & rsMain.Fields("1Rev")
LoadFrm.ComboBoxAssembly.AddItem
LoadFrm.ComboBoxAssembly.list(i, 1) = rsMain.Fields("2Assy") & " Rev: " & rsMain.Fields("2Rev")
LoadFrm.ComboBoxAssembly.AddItem
LoadFrm.ComboBoxAssembly.list(i, 2) = "Date Issued: " & rsMain.Fields("DateIn")
LoadFrm.ComboBoxAssembly.AddItem
LoadFrm.ComboBoxAssembly.list(i, 3) = rsMain.Fields("ID")
i = i + 1
LoadFrm.ComboBoxAssembly.ListRows = i

Else
End If

rsMain.MoveNext
Loop
 



You don't have to add ANYTHING to the database, in order to run a query on tables in that database.

You can use ADO to query the database or MS Query.

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
do you not have something like

set rsmain = dbsName.openRecordset("SELECT * FROM Employees)

if so change to

set rsmain = dbsName.openRecordset("SELECT * FROM Employees order by XXXX)

If you do not have this post your code that declares your recordset

ck1999
 
Thanks guys. Worked like a champ!
 

I would just suggest NOT using the default properties, but fully qualify it:
Code:
If rsMain.Fields("BU")[red].Value[/red] = Me.TextBoxCust[red].Text [/red]Then

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top