Advertisement

11.21.2005 at 01:29PM PST, ID: 21638715
[x]
Attachment Details

SQL Statement INSERT causing -2147217900 80040e14 error.  Need help defining logic to prevent error.

Asked by stephenlecomptejr in Microsoft Access Database

Tags: 2147217900

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!

StephenStart Free Trial
 
 
[+][-]11.21.2005 at 01:34PM PST, ID: 15337328

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.21.2005 at 02:18PM PST, ID: 15337692

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.21.2005 at 02:29PM PST, ID: 15337778

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.21.2005 at 02:32PM PST, ID: 15337817

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.21.2005 at 02:36PM PST, ID: 15337836

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.21.2005 at 02:38PM PST, ID: 15337860

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.21.2005 at 02:44PM PST, ID: 15337902

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.21.2005 at 02:55PM PST, ID: 15338015

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.21.2005 at 03:01PM PST, ID: 15338079

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.21.2005 at 03:04PM PST, ID: 15338117

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.21.2005 at 03:15PM PST, ID: 15338185

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.21.2005 at 05:26PM PST, ID: 15338945

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.21.2005 at 07:43PM PST, ID: 15339442

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Access Database
Tags: 2147217900
Sign Up Now!
Solution Provided By: capricorn1
Participating Experts: 4
Solution Grade: A
 
 
[+][-]11.22.2005 at 03:16AM PST, ID: 15340835

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]11.22.2005 at 07:32AM PST, ID: 15342543

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.22.2005 at 08:06AM PST, ID: 15342883

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.22.2005 at 08:07AM PST, ID: 15342890

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.22.2005 at 12:46PM PST, ID: 15345376

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.22.2005 at 01:32PM PST, ID: 15345787

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32