problem with joined tables and exception error

T

TM

I have a problem with a joined table if the user enters a new record, but
there is no associated
record for the new isle entered in the IsleSOrt order table.

TableName: IsleSortOrder
Field1: IsleID (text field)
Field2: SpecialSort (number field)
isleid contains ENT, PROD, PHRM, and numbers 00-16

select statement:
"SELECT ShoppingList.Isle, ShoppingList.Item FROM ShoppingList INNER JOIN
IsleSortOrder
ON ShoppingList.Isle = IsleSortOrder.IsleID ORDER By
IsleSortOrder.SpecialSort"

I entered a new record with isle as ENN instead of ENT by mistake. It did
not show in the datagrid. But if I open the access file in access, the
record with the wrong isle is in there.

So when I did it again later by mistake the second item, it displays this
error:
An unhandled exception of type "system.data.oledb.oledbexception: occured in
system.data.dll

The exception desctiption is as follows:
The changes you requested to the table were not successful because they
would create duplicate values in the index, primary key, or relationship.
Change the data in the field or fields that contain duplicate data, remove
the index, or redefine the index to permit duplicate entries nd try again.

What I did was try and enter a new record, and typoed the isle, and entered
ENN instead of ENT, and it blew up. If I enter a new isle that contains a
reference in the islesort table it works fine. BUt if I enter an isle that
does not contain a refernece in the islesort table it blows up.

I think I found out part of the problem but am not sure how to fix it.

It is actually allowing me to enter a new record if there is no associated
isle in the islesort table. But, when I look at the database using the
custom join bound to a datagrid, it only returns records that have an isle
entry in the islesort table.

So the record is allowed to be entered but just does not show with the
select statement and that is causing the problem

Any idea how to fix this ?

Thanks
 
Top