Member_2_1242703
asked on
Populating a Combo Box
I have an SQL DB with a table named EmployeeData. It has a column named EmployeeName.
I have a form with a drop down called cmbName
When the form loads I want to populate the drop down in alphabetic order with the data from the EmployeeName column.
I have a form with a drop down called cmbName
When the form loads I want to populate the drop down in alphabetic order with the data from the EmployeeName column.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
carl_tawn's got it.
(i left the connection object out of mine, sorry)
(i left the connection object out of mine, sorry)
Great minds think alike :o)
Yep
ASKER
Sweet. Thanks guys, I see what I was doing wrong now. THANKS!!!
this should do it:
Dim sSQL As String
sSQL = "SELECT EmployeName FROM EmployeeData ORDER BY EmployeeName"
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open sSQL, Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
Do While rs.EOF = False
cmbName.AddItem rs.Fields("EmployeeName").
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
bkt