2016-07-14 5 views

ответ

0

Это прямо из VbForums (я не несу кредит для кода!), Первый результат для быстрого поиска Google.

Dim strSQL as String 'Declare the variables we need 
Dim oRS as ADODB.Recordset 
    Set oRS = New ADODB.Recordset 

          'Load the data 
'** change this SQL to load the data you want. 
    strSQL = "SELECT Colour FROM Colours" 

'** change oConn to the name of your Connection object 
    oRS.Open strSQL, oConn, adOpenForwardOnly, adLockReadOnly, adCmdText 
          'Fill the combo box (or ListBox) 
'** change the name of the combo to the one you want to fill 
    With cboColour 
    .Clear 
    Do While Not oRS.EOF 
'** change the name of the field here to the one you want to show 
     .AddItem oRS.fields("Colour").value 
     oRS.MoveNext 
    Loop 
    End With 

          'Tidy up 
    oRS.Close 
    Set oRS = Nothing 
Смежные вопросы