INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

can't append all the records in the query

can't append all the records in the query

(OP)
I've got an issue trying to do an INSERT INTO command from Access 2003 to a SQL server 2000 Database.  All the 'temp' tables are Access tables and All others are SQL tables.

If I used the db.excute with dbfailerror I get an ODBC--Failed error.

If I use the following DoCmd.RunSQL I get the 'Can't append' error.

The First command will run, but the reset won't with key violations - but there are no key violations.  If I wait for a period of time and switch the order then the one that ran previously won't and the new first one will.  

Any help would be greatly appreciated.  Below is my current code

intQuoteID = 354

    DoCmd.RunSQL ("INSERT INTO dbo_Quote SELECT * FROM dbo_Quote_Temp WHERE QuoteID = " & intQuoteID & ";"), dbSeeChanges
    DoCmd.RunSQL ("INSERT INTO dbo_QuoteDetail SELECT * FROM dbo_QuoteDetail_Temp WHERE QuoteID = " & intQuoteID & ";"), dbSeeChanges
    DoCmd.RunSQL ("INSERT INTO dbo_QuoteSubRouting SELECT * FROM dbo_QuoteSubRouting_Temp WHERE QuoteID = " & intQuoteID & ";"), dbSeeChanges
    DoCmd.RunSQL ("INSERT INTO dbo_QuoteRouting SELECT * FROM dbo_QuoteRouting_Temp WHERE QuoteID = " & intQuoteID & ";"), dbSeeChanges
    DoCmd.RunSQL ("INSERT INTO dbo_QuoteGradeMakeup SELECT * FROM dbo_QuoteGradeMakeup_Temp WHERE QuoteID = " & intQuoteID & ";"), dbSeeChanges
    DoCmd.RunSQL ("INSERT INTO dbo_QuoteQty SELECT * FROM dbo_QuoteQty_Temp WHERE QuoteID = " & intQuoteID & ";"), dbSeeChanges
 

RE: can't append all the records in the query

how about

CODE

DoCmd.RunSQL "INSERT INTO dbo_Quote SELECT * FROM dbo_Quote_Temp WHERE QuoteID = " & intQuoteID & ";"
    DoCmd.RunSQL "INSERT INTO dbo_QuoteDetail SELECT * FROM dbo_QuoteDetail_Temp WHERE QuoteID = " & intQuoteID & ";"
    DoCmd.RunSQL "INSERT INTO dbo_QuoteSubRouting SELECT * FROM dbo_QuoteSubRouting_Temp WHERE QuoteID = " & intQuoteID & ";"
    DoCmd.RunSQL "INSERT INTO dbo_QuoteRouting SELECT * FROM dbo_QuoteRouting_Temp WHERE QuoteID = " & intQuoteID & ";"
    DoCmd.RunSQL "INSERT INTO dbo_QuoteGradeMakeup SELECT * FROM dbo_QuoteGradeMakeup_Temp WHERE QuoteID = " & intQuoteID & ";"
    DoCmd.RunSQL "INSERT INTO dbo_QuoteQty SELECT * FROM dbo_QuoteQty_Temp WHERE QuoteID = " & intQuoteID & ";"
 

RE: can't append all the records in the query

(OP)
That didn't work either.  I believe it has something to do with the indexes on the SQL server even though the record no longer exist (I delete it just before I'm trying to insert from the temp table) it still runs into a validation problem.

If I remove the Primary Keys and the Relationships then it works.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close