Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse a DBCombo control bound at design time
KeywordsDBCombo, DataCombo, ComboBox
CategoriesControls
 
At design time, create a Data control (datCountries). This control determines the choices allowed in the DBCombo's dropdown list. Set the RecordSource property to the SQL query or table name that will select the values that are allowed in the DBCombo.

Create another Data control (datCompanies). This control determines the values selected for the fields bound for a particular record. Set its RecordSource property to select the data you want to display.

In this program, for example, the datCompanies control selects values from the Companies table including one field named Country. Each record in the Companies table has a single value in the Country field. That value must be one of those listed in the Countries table selected by datCountries.

Next create a DBCombo control (and any other controls you want bound to datCompanies). Set its DataSource property to the Data control that selects the records you want to display (datCompanies) and set the DataField property to the field that should be displayed by the DBCombo (Country).

Now set the RowSource property to the Data control that selects the allowed values for the DBCombo (datCountries) and set its ListField property to the field selected by that Data control that contains the allowed values. In this example, that is the field called Name in the Countries table.

PropertyValue
DataSourcedatCompanies
DataFieldCountry
RowSourcedatCountries
ListFieldName

Finally, at runtime, attach the Data controls to the databases (you could do this at design time if you knew the databases wouldn't move later). Note that in this program both tables are in the same database.

 
Private Sub Form_Load()
    datCountries.DatabaseName = App.Path & "\dbcombo.mdb"
    datCompanies.DatabaseName = App.Path & "\dbcombo.mdb"
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated