Листинг 2
Private Sub LoadComboBox()
' формирование списка сотрудников
Dim con As New ADODB.Connection, rs As New ADODB.Recordset
Dim sSQL As String, objEntry As Object, iCnt As Integer
' формирование запроса открытрие базы данных
sSQL = "Select EmployeeID, FirstName + ' ' +" _ &
"LastName as Name from Employees"
con.open "Provider=Microsoft.Jet.OLEDB.3.51; " & _
"Persist Security Info=False;Data Source=c:\Nwind.mdb"
rs.open sSQL, con, adOpenKeyset, adLockReadOnly
' Формирование списка
Do Until rs.EOF
Set objEntry = Document.createElement("option")
objEntry.Text = rs("Name")
cboEmpNames.Add objEntry
cboEmpNames(iCnt).Value = rs("EmployeeID")
rs.MoveNext
iCnt = iCnt + 1
Loop
rs.Close
con.Close
End Sub