Есть подключение к базе
Private Sub Form_Load()
Dim ConnectionString As String
ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=C:\Program Files\VB\Nwind.mdb;" & "Uid=;Pwd="
With Adodc1
.RecordSource = _
"SELECT ProductName, ProductID, SupplierID FROM Products"
.ConnectionString = ConnectionString
.Refresh
.Caption = "Products"
.Visible = False
End With
With Adodc2
.RecordSource = "SELECT CompanyName, SupplierID FROM Suppliers"
.ConnectionString = ConnectionString
.Refresh
.Caption = "Suppliers"
.Visible = False
End With
Set DataGrid1.DataSource = Adodc1
With DataCombo1
Set .DataSource = Adodc1
.DataField = "SupplierID"
.BoundColumn = "SupplierID"
Set .RowSource = Adodc2
.ListField = "CompanyName"
End With
Adodc1.Recordset.MoveFirst
End Sub
Но здесь надо обязательно на форме разместить Adodc1 и Adodc2.
1. Можно-ли обойтись без них?
2. Могу ли я написать вместо
With DataCombo1
Set .DataSource = Adodc1
.DataField = "SupplierID"
вот так
Set DataCombo1.DataSource = Adodc1
DataCombo1.DataField = "SupplierID"