Dynamically bind a DataList or DataCombo control to an ADO Recordset

When dynamically changing the bound ADORecordset for a DataCombo or DataList control, the order you follow when assigning the properties is important. This is the correct sequence of operations to perform to change the bound recordset for these controls:

' unbind the current sourcesSet DataCombo1.DataSource = NothingSet DataCombo1.RowSource = Nothing' set the new binding - start with the string propertiesDataCombo1.DataField = "ProductID"    ' the bound field in master tableDataCombo1.BoundColumn = "ID"         ' the bound field in detail tableDataCombo1.ListField = "ProductName"  ' the display field in detail tableSet DataCombo1.RowSource = rsProducts ' the detail tableSet DataCombo1.DataSource = rsOrder   ' the master table

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: