Results 1 to 2 of 2
  1. #1
    donavan01 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    8

    Moving records from one table to another

    I need a sql statement that will allow me to move data from one table to another (not copy but move) currently I am using the following code



    Code:
     Dim db As Database
     Set db = CurrentDb
     db.Execute "Insert INTO archive SELECT * FROM Main"
     db.Execute "DELETE FROM [Main]"
    However it seems to have some issues because it wants to delete the records before everthing is moved. I have another option which is:

    Code:
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qryArchive"
    DoCmd.SetWarnings True
    with a query of:

    Code:
    Insert INTO archive SELECT * FROM Main
    DELETE FROM [Main]
    But I dont know if this will guarentee a correct transfer of the data either.


    Any Suggestions?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Your other option is not actually an option, since you can't have more than one SQL statement in a query (in Access anyway). You can try adding DoEvents between the two Execute lines and see if that helps. Generally archiving isn't necessary anyway.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Having trouble with moving text to table
    By geoffwbailey in forum Programming
    Replies: 3
    Last Post: 06-17-2010, 11:00 AM
  2. Moving data from one table to another?
    By Maverick1501 in forum Access
    Replies: 2
    Last Post: 03-15-2010, 08:08 AM
  3. Moving through records via Page Down
    By Robert M in forum Programming
    Replies: 4
    Last Post: 07-28-2009, 09:21 AM
  4. Moving records up
    By saqqer in forum Programming
    Replies: 0
    Last Post: 07-27-2009, 08:29 AM
  5. Moving Records Between Databases
    By sscott in forum Access
    Replies: 2
    Last Post: 03-22-2009, 09:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums