Populate a combo box from a database backend without using an ADODC Control.
Populate a combo box from a database backend without using an ADODC Control.
API Declarations
Dim Con as ADODB.Connection
Dim ssql as String
Const strCon =_ "DSN=Contacts;Description=Contacts;SERVER=ServerName;UID=sa;Password=;"
Rate Populate a combo box from a database backend without using an ADODC Control.
(1(1 Vote))
Set Con = New ADODB.Connection
Set rs = New ADODB.Recordset
Con.Open strCon
'sql statement to select items on the drop down list
ssql = "Select LastName From Contacts"
rs.Open ssql, Con
Do Until rs.EOF
combo1.AddItem rs("LastName") 'Adds lastnames to dropdown list
rs.MoveNext
Loop
'Close connection and the recordset
rs.Close
Set rs = Nothing
Con.Close
Set Con = Nothing
End Sub
Populate a combo box from a database backend without using an ADODC Control. Comments
No comments yet — be the first to post one!
Post a Comment