I have a form with a bindingsource (bsMain) and a combobox (cboLinkID).
The bsMain properties are as follows.
The cboLinkID is bound as follows.Code:With bsMain .DataMember = "Accounts" '...this is the Accounts table in the dsMain dataset .DataSource = dsMain End With cboLinkID.DataBindings.Add(b)
The above code is executed with the form's Load method.Code:With cboLinkID .ValueMember = "RecID" '...this is the primary key field of the Accounts table .DisplayMember = "Account" '...this is the Account field of the Accounts table (i.e., account names) .DataSource = dsMain.Tables("Accounts") End With b = New Binding("SelectedValue", bsMain, "LinkID") With b .DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged End With cboLinkID.DataBindings.Add(b)
When the form opens, the selected item's cboLinkID drop-down list shows all the account names in the Accounts table. The cboLinkID.SelectedValue shows the name of the linked account. This is the expected behavior.
But when I navigate to another record, then the cboLinkID drop-down list now has no items and the cboLinkID.SelectedValue is blank.
Closing/reopening the form repeats the above behavior.
What am I doing wrong?




Reply With Quote
