Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 5th, 2008, 10:44 AM
Authorized User
 
Join Date: Feb 2008
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hewstone999
Default Insert table records into another table.

I have this query below:

INSERT INTO TEST_DOC
SELECT *
FROM MPI_ADDSS_IFF;

I currently have 10 tables in my database (All with the same colunm names and formats) however i want to click a button that will put all the tables into TEST_DOC, instead of doing it one by one. To do this this i would like some code either in SQL or VBA that will do this.

Any ideas or help?

Kind Regards
Hewstone999


 
Old March 5th, 2008, 11:01 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

The easiest way to do this is to create 10 Update queries (after you run an Delete query on the receiving table to remove old data.) That would look like this:

DoCmd.SetWarnings False
DoCmd.OpenQuery "qryDELETE_OldData"
DoCmd.OpenQuery "qryAPPEND_Table01"
DoCmd.OpenQuery "qryAPPEND_Table02"
DoCmd.OpenQuery "qryAPPEND_Table03"
DoCmd.OpenQuery "qryAPPEND_Table04"
DoCmd.OpenQuery "qryAPPEND_Table05"
DoCmd.OpenQuery "qryAPPEND_Table06"
DoCmd.OpenQuery "qryAPPEND_Table07"
DoCmd.OpenQuery "qryAPPEND_Table08"
DoCmd.OpenQuery "qryAPPEND_Table09"
DoCmd.OpenQuery "qryAPPEND_Table10"
DoCmd.SetWarnings True

Did that help?


mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old March 5th, 2008, 11:01 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Sorry, create 10 APPEND queries, not Update queries.

mmcdonal

Look it up at: http://wrox.books24x7.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Connecting to a table to read and insert records mnolting Word VBA 0 October 1st, 2008 11:39 PM
insert multiple records into a table from values Deepak Chauhan Oracle 3 May 12th, 2006 10:35 PM
Insert multiple records in a Inner Join Table rylemer Access 1 August 22nd, 2004 07:44 AM
Insert multiple records in a Inner Join Table rylemer Access VBA 0 July 19th, 2004 03:54 PM
thousands records enter one table to another table mateenmohd SQL Server 2000 3 July 17th, 2003 07:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.