N
njb35
Hi all
I'm beginning my foray from VBA into VB 2005 Express, and enjoying
some of the efficiencies it provides! I'm stuck with some dataset
handling however that I _think_ can be automated but I can probably
code what I want to do the hard way. I've searching around online but
can't find an answer to this specific question.
Here's the situation: I have a dataset table with 3 fields: one
indexed as a primary key and the other two not. The indexed field is
bound to a combo box. When the program loads, the dataset data and
schema are loaded from disk and the combobox is automatically (!)
filled with the appropriate items because it's bound to that dataset.
Yay! The two other fields are bound to a numericUpDown and a TextBox
respectively and are also filled with their correct data from the
first entry of the dataset.
I also have a BindingNavigator in the mix. When I use the Navigator
within the running program to move between records, the ComboBox,
NumericUpDown and the TextBox all update correctly with their
appropriate data. So far it looks great - I'm very impressed with
everything and my coding effort has been almost zero.
What I want to do is select an entry using the combobox - this is far
more intuitive for the user than searching using the arrow buttons in
the BindingNavigator. However, when I use the combobox to select an
entry from the dropdown I get a ConstraintException because the
system thinks I'm trying to enter a NEW entry into the dataset using a
duplicate name in the primary key column of the table.
Is there a simple way to use a pre-filled and bound combobox to
_select_ an existing row of data from a dataset and have the other
bound items all update to the same row rather than have the program
think I'm trying to _enter_ a new row of data? I've seen some
examples talk about using a second table linked to the combobox but I
can't see how that will avoid the problem of the program thinking it's
a new field and not a selection of an existing one.
Thanks for any advice or help
Bennett
I'm beginning my foray from VBA into VB 2005 Express, and enjoying
some of the efficiencies it provides! I'm stuck with some dataset
handling however that I _think_ can be automated but I can probably
code what I want to do the hard way. I've searching around online but
can't find an answer to this specific question.
Here's the situation: I have a dataset table with 3 fields: one
indexed as a primary key and the other two not. The indexed field is
bound to a combo box. When the program loads, the dataset data and
schema are loaded from disk and the combobox is automatically (!)
filled with the appropriate items because it's bound to that dataset.
Yay! The two other fields are bound to a numericUpDown and a TextBox
respectively and are also filled with their correct data from the
first entry of the dataset.
I also have a BindingNavigator in the mix. When I use the Navigator
within the running program to move between records, the ComboBox,
NumericUpDown and the TextBox all update correctly with their
appropriate data. So far it looks great - I'm very impressed with
everything and my coding effort has been almost zero.
What I want to do is select an entry using the combobox - this is far
more intuitive for the user than searching using the arrow buttons in
the BindingNavigator. However, when I use the combobox to select an
entry from the dropdown I get a ConstraintException because the
system thinks I'm trying to enter a NEW entry into the dataset using a
duplicate name in the primary key column of the table.
Is there a simple way to use a pre-filled and bound combobox to
_select_ an existing row of data from a dataset and have the other
bound items all update to the same row rather than have the program
think I'm trying to _enter_ a new row of data? I've seen some
examples talk about using a second table linked to the combobox but I
can't see how that will avoid the problem of the program thinking it's
a new field and not a selection of an existing one.
Thanks for any advice or help
Bennett