D
Dave
Hi I am trying to add a record to a table
My code is as follows:
Dim rs As New ADODB.Recordset
rs.Open "SELECT EmpJobID, JobID, EmpID FROM tblEmpJob",
CurrentProject.Connection, adOpenKeyset, adLockPessimistic
With rs
.AddNew
!JobID = lngJobID
!EmpID = intEmpToID
.Update
End With
rs.Close
Set rs = Nothing
It is failing on the update. The error is
Run Time error -2147217887 (80040e21)
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 copntacin
the duplicate data, remove the index, or redefine the index to permit
duplicate entries and try again.
Neither JobID nor EmpID are unique.
This code has run before many hundreds of times - the only thing I can
think of is that the table is now getting large, with the unique key
(which is an autonumber) now at 264135
Thanks
My code is as follows:
Dim rs As New ADODB.Recordset
rs.Open "SELECT EmpJobID, JobID, EmpID FROM tblEmpJob",
CurrentProject.Connection, adOpenKeyset, adLockPessimistic
With rs
.AddNew
!JobID = lngJobID
!EmpID = intEmpToID
.Update
End With
rs.Close
Set rs = Nothing
It is failing on the update. The error is
Run Time error -2147217887 (80040e21)
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 copntacin
the duplicate data, remove the index, or redefine the index to permit
duplicate entries and try again.
Neither JobID nor EmpID are unique.
This code has run before many hundreds of times - the only thing I can
think of is that the table is now getting large, with the unique key
(which is an autonumber) now at 264135
Thanks