473,396 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem of transferring data from one table to another in the same DB

Dear All,

I am facing a problem of transferring data between 2 tables within the same database.

I set up 2 tables. The first table is the permanent table (oos_table) for saving records. the other table is a temp table (oos_table_temp) for storing records which all data would be deleted after the data transferred to the permanent table.

below is the code I am currently using.
Expand|Select|Wrap|Line Numbers
  1. Dim strNewTable As String
  2. Dim strOldTable As String
  3. strNewTable = "oos_table"  
  4. strOldTable = "oos_table_temp"  
  5.  
  6. DoCmd.TransferDatabase acExport, "Microsoft Access", CurrentDb.Name, acTable, strOldTable, strNewTable, False
  7.  
the above code works in the first time and can transfer all data in the temp table to the permanent one.

But when doing the second time, the previously data in the permanent table will be replaced by the new temp table data.

The problem is, I want to keep te previous data in the permanent table and add the data in the temp table to it. not replacing the existing data.

Could anyone help with this?

Thanks a million.
Nov 20 '09 #1

✓ answered by topher23

@orangeCat
orangeCat's got the solution, but that doesn't tell you why what you're doing now doesn't work.

The TransferDatabase method doesn't copy the data, it copies the table. So, if you already have a table with the new table name you specify in TransferDatabase, it will be overwritten by the other table.

Think of it like a Word document. If you create 2 Word documents, then save the second document with the first document's name, it doesn't append the second document's text to the first document, it just deletes the first document and saves the second document with the new name. That's what you're doing with the TransferDatabase method.

So, what you need to do is use an Append query. An Append query can take the data from your temp table and add it to the permanent table by appending the new data to the existing data in the table.

The first bit of SQL OrangeCat gave you is the Append Query. The second is a delete query to remove everything from the temp table after it is appended to the permanent table.

3 2654
orangeCat
83 64KB
Suggest you look at SQL statement
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO oos_table
  2. SELECT *
  3. FROM oos_table_temp
You'll also need SQL to :
Expand|Select|Wrap|Line Numbers
  1. DELETE
  2. FROM oos_table_temp
after you have moved the data from oos_table_temp to oos_table
Nov 20 '09 #2
topher23
234 Expert 100+
@orangeCat
orangeCat's got the solution, but that doesn't tell you why what you're doing now doesn't work.

The TransferDatabase method doesn't copy the data, it copies the table. So, if you already have a table with the new table name you specify in TransferDatabase, it will be overwritten by the other table.

Think of it like a Word document. If you create 2 Word documents, then save the second document with the first document's name, it doesn't append the second document's text to the first document, it just deletes the first document and saves the second document with the new name. That's what you're doing with the TransferDatabase method.

So, what you need to do is use an Append query. An Append query can take the data from your temp table and add it to the permanent table by appending the new data to the existing data in the table.

The first bit of SQL OrangeCat gave you is the Append Query. The second is a delete query to remove everything from the temp table after it is appended to the permanent table.
Nov 20 '09 #3
Thanks orangeCat for helping and topher23 for your detail explaination. These helps a lot.
Nov 23 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Raja | last post by:
I am transferring data from SQl Server 2000 to Oracle through Linked Servers.It takes considerable amount of time while transferring data from SQL Server to oracle.Both these databases are at...
3
by: phong.lee | last post by:
Hello all, i'm new at this. I need some assistant in transferring data from excel to access. I created a macro that basically gather all the necessary data that i need to bring into access. I...
11
by: Abhishek | last post by:
I have a problem transfering files using sockets from pocket pc(.net compact c#) to desktop(not using .net just mfc and sockets 2 API). The socket communication is not a issue and I am able to...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
2
by: Rani | last post by:
hi guys I don't know if this is the right place for it but I created 2 pages in page one there is a text box in which the user enters his name, in page 2 there is a the same text box. I would...
15
by: http://www.visual-basic-data-mining.net/forum | last post by:
Does anyone have any idea how to transferring data from TextBox1 in form1 to textBox2 in form2..... That means after i fill in any data in textBox1 and click Next button... It will bring me to...
2
by: neilr | last post by:
Can anyone help with some problkems that have wasted 2 days of my (inexperienced) time already? We have a website which allows people to register for events like conferences We are importing...
5
by: meetalps | last post by:
Hi All, Can you please help me with a step by step procedure to transfer files from my PC to DB2-AIX and vice versa. I am new to both. Example transferring a sql file to run from PC to DB2 on AIX....
0
OuTCasT
by: OuTCasT | last post by:
I have a table on one server and another on another server. I transfferred that data from the old table to the new table but some of the data didnt pull through. there is an email column in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.