Problem moving between data

johncassell

Well-known member
Joined
Jun 10, 2007
Messages
120
Location
Redcar, England
Programming Experience
Beginner
Hi There,

can anyone help with this problem please...

I have a table called Price Bands with 3 columns (Primary key is the Price Band ID, second column is RRP, third column is Barcode.)

I have created a form with a combobox for the Price Band ID and text boxes for the other two table columns.

Form loads with the first entry from the table loaded.

Problem is that when i try to move (using the drop down) to the second entry (price ID is '2') it is thinking that I am trying to create a new value called 2 when there is already one in there.

All I want to do is select the Price ID '2' so I can view and maybe edit it.

Can anyone point me in the right direction please?

Thanks

John
 

Attachments

  • errorUnique.JPG
    errorUnique.JPG
    36.2 KB · Views: 34
Combos can either be used to navigate OR to edit. They cannot be used for both. If a combo has any databindings other than just the .DataSource, it will attempt to edit.

i.e. your combo currently has its .Text property bound to the MyDataTable.MyXYZColumn
The combo will always try to edit this column with its current text.

Remove this binding. and you can nav. Of course, it means this combo cannot be used to edit this value, but this value is a PK, it shouldnt be edited anyway

Perhaps if it is to be edited one time, then you can bind a textbox to it also, and Hide/Show the TextBox/Combo depending on whether the DirectCast(BindingSource.Current, DataRowView).Row.RowState is Added or Modified
 
Hi cjard,

thanks for the reply,

think I understand the problem now. I am going to hide the bound combo and use a separate combo to do the navigation and tie them together somehow.

hopefully I know what I am doing now! :)

Thanks very much

John
 
you'll have 1 combo box which has SelectedValue set, and the other won't. the one that doesn't is the one you use for navigating.

And the one that does, shouldnt exist, because we dont edit primary keys!
 
All I want to do is select the Price ID '2' so I can view and maybe edit it.

You mean edit the details "for" that ID??? If so then we're showing you the right direction. As Cjard has said, if you're saying you want to edit the ID field, i.e. change 1 to I dunno, A, then don't !
 
Back
Top