Results 1 to 5 of 5
  1. #1
    worldwidewall is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2012
    Posts
    23

    Make Table Query Question


    I have a make table query that I want to use to overwrite an existing table. But the existing table has relationships that I don't want to delete. I want the old table to contain the data from the results of the make table query without deleteing the relationships.

    How do I do this?

    Thanks

    Dave

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Is the table structure unchanged? Instead of overwriting table, you could delete all records and then insert the new set of records.

    If you are changing table structure, then don't think can use MakeTable and overwrite without removing relationships. An alternative might be to use VBA and ALTER TABLE sql action to restructure the table. Then delete records and insert new records. Another alternative might be VBA code to modify the table properties with TableDefs (remove the relationships, overwrite table, reset relationships). As you can see, gets complicated.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    worldwidewall is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2012
    Posts
    23
    The table structure remains completely unchanged, just new data. How could I remove all the old data and add the new in vba?

    Thanks

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Run DELETE and INSERT actions. You can either build and save queries with Access query designer and run them or construct the SQL statement in VBA.

    This will execute an Access saved query
    DoCmd.OpenQuery "query name"

    This will execute an SQL statement:
    CurrentDb.Execute "DELETE FROM tablename"
    CurrentDb.Execute "INSERT INTO ... SELECT ..."

    Review http://msdn.microsoft.com/en-us/library/ms188263.aspx for specifics on the INSERT SELECT statement.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    worldwidewall is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2012
    Posts
    23
    Thanks

    I will give it a go.

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

Similar Threads

  1. Make Table Query
    By Lpitt56 in forum Access
    Replies: 3
    Last Post: 08-18-2011, 12:27 PM
  2. Replies: 1
    Last Post: 07-30-2010, 10:28 AM
  3. Make table query
    By Zahed in forum Queries
    Replies: 1
    Last Post: 11-06-2009, 05:44 AM
  4. Replies: 2
    Last Post: 10-27-2009, 07:09 AM
  5. Make a table query
    By Fiona in forum Access
    Replies: 4
    Last Post: 06-25-2009, 11:24 AM

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