binding a combobox to a dataset and value changes appropriately for current record (1 Viewer)

joe789

Registered User.
Local time
Today, 22:16
Joined
Mar 22, 2001
Messages
154
Binding a combobox to a dataset and value changes appropriately for current record selected?

I have a dataset in a vb.net form that is linked successfully to a sql server table with fields from the table being displayed on the form appropriately. I have created a combobox and populated it with a collection of items the user can select from. I am attempting to bind that combobox to a field in the linked table, so that as the user navigates thru the records in the dataset the appropriate value is displayed in the combobox and if a user selects a value from within the combobox that value is automatically updated/replaced/changed in the appropriately bound field. I am wrestling with this one - any help would be greatly appreciated. Thanks!
 

DirtDiverKF

Registered User.
Local time
Today, 14:16
Joined
Oct 17, 2011
Messages
12
Same issue i am having except not with sql on line, just in access
 

Estuardo

Registered User.
Local time
Today, 22:16
Joined
May 27, 2003
Messages
134
G'd Evening!
Joe: When you bind your txtboxes you can bind your combobox as well. You just have to be sure that it is populated before binding. Then you can do something like this:
Me.cboYourCombobox.Value = CInt(YourObject("YourTableField")).
YourObject is anything that supports the IEnumerable interface, might be a dataset, datatable, arrays, a class etc.

DirtDiver:
In ms access you just have to use the Form_Current() event and set your combobox to a table's field like this:
Me.cboYourCombo = Me.txtPKField

G'd luck
 

Users who are viewing this thread

Top Bottom