I get an error -2147217900 (80040e14) run-time error. 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 and try again.
The following code is listed here:
For Each objItem In colName
i = i + 1
sSelect = "INSERT INTO [Access_CHANGES] (fDBID, fUserID, fName, fType, fDate, fCreated) "
sSelect = sSelect & " VALUES (" & lDB & ", " & lUser & ", '" & objItem & "', " & colType(i) & ", '" & colDate(i) & "', " & colCreated(i) & ")"
m_cnSQLData.Execute sSelect
Next objItem
If I do a:
Print sSelect - I get:
INSERT INTO [Access_CHANGES] (fDBID, fUserID, fName, fType, fDate, fCreated) VALUES (17, 37, 'MSysAccessObjects', 1, '11/21/2005 3:07:16 PM', True)
And obviously according to the error I have this record already in the table!
So this is working good but I would rather not allow this error come up.
What set of SQL statements should I write in verifying this exists already instead of just writing a INSERT command?
I am rather of the mind set to not allow an error to occur in the first place if possible to prevent instead of just Resume Next as I have it in this module. Some global variables (which is few in this case) with their values get lost.
Thanks for any suggestions!
Stephen
Start Free Trial