How To Bind a DataList or DataCombo to a Recordset at Run Time
Article ID: 189682
Article Last Modified on 6/29/2004
APPLIES TO
- Microsoft Visual Basic 6.0 Professional Edition
- Microsoft Visual Basic 6.0 Enterprise Edition
This article was previously published under Q189682
SUMMARY
When binding a DataList or a DataCombo control to an ADO recordset at run
time, follow the steps below:
DataCombo1.DataField = "DestinationBoundField"
DataCombo1.BoundColumn = "SourceBoundField"
DataCombo1.ListField = "SourceDisplayField"
Set DataCombo1.RowSource = rsSourceRecordset
Set DataCombo1.DataSource = rsDestinationRecordset
For example, you may want to maintain an EmployeeID field in an Orders
table; however, you would want to allow the user to select the appropriate
employee information by the employee's name, rather than by the EmployeeID
field.
In this case, the destination for the selection from the combo box is the
EmployeeID field in the Orders recordset. But the source for this
information is the recordset containing information from the Employees
table.
The ListField property should be set to the field whose information you
want to display; while the BoundColumn property should be set to the field
whose information you want to bind to the destination recordset. In this
case, the ListField would be EmployeeName and the BoundColumn would be
EmployeeID.
Additional query words: DataList DataCombo kbdse kbDSupport kbVBp kbvbp600 kbDataBinding
Keywords: kbhowto KB189682