Please help me a piece of code loading data from recordset into combo box.
Thanks!

once you have your rs setup you can do this

Do Until rs.EOF
        Combo1.AddItem rs!Field
        rs.MoveNext
    Loop

attached the following code on form load event:

rec.MoveFirst
while not rec.EOF

combo1.addItem(rec.("Field Name"))
rec.moveNext
wend

Private Sub Form_Load()
Call con
'Fill The Combo box
While rs.EOF <> True
Combo1.AddItem rs!field
rs.MoveNext
DoEvents 'Add this code so that the system will not freeze...
Wend
Combo1.Enabled = False
End Sub
Public Sub con()

'Open The Connection
cn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Jet OLEDB:Database Password=;")

'Open The Recordset
rs.Open "SELECT * FROM Table1", cn, adOpenStatic, adLockOptimistic

End Sub

please find the following code
----------------------------------------
Dim rs as Recordset
Set rs = New Recordset
sSQL = "SELECT GroupNo FROM CenterMembers "
rs.Open sSQL, con, adOpenForwardOnly, adLockOptimistic
Combo1.clear
While Not rs.EOF
Combo1.AddItem rs!GroupNo
rs.MoveNext
Wend
rs.Close
--------------------------------------------
Note that con is connection object

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.