Solved

Move data between databases

Posted on 1998-10-02
8
120 Views
Last Modified: 2010-04-30
Using the Create database nd Create tables, I create these along with fields to match an existing database with a different name. Is there an easy way to move data to the new database and wipe out the records from the existing one besides going through every field.
Thanks
0
Comment
Question by:robhas
  • 4
  • 4
8 Comments
 
LVL 14

Accepted Solution

by:
waty earned 150 total points
ID: 1437795
DB.Execute "Delete from Customers"

DB.Execute " INSERT INTO Customers " _
            & "SELECT * " _
            & "FROM [New Customers];"
            
      
0
 

Author Comment

by:robhas
ID: 1437796
Could you please be a little more specific about copying the records. The table I need to copy to is in an entirly different database.
Thanks
0
 
LVL 14

Expert Comment

by:waty
ID: 1437797
You could use as following :

sSQL = "Select * from Table1"
set Record = DB1.OpenRecordset(sSQL, dbOpenDynaset)

if record.RecordCount > 0 then
   record.Movelast
   record.MoveFirst

   ' *** Ignore duplicates
   On error Resume Next

   For nI = 1 to record.RecordCount
      ' *** Construct here your insert
      sSQL = "Insert Into ....." & record("YourField")...

      DB.Execute SQL    

   Next

End If

Otherwise, your database are 2 Access database?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:robhas
ID: 1437798
I successfully coded the area to delete all records from a table but I am still having problems copying the data from a table to a different database.  I am using this statement below but I keep receiving a syntax error. Can not figure out what is wrong.
Thanks
0
 
LVL 14

Expert Comment

by:waty
ID: 1437799
Post your code, I will check
0
 

Author Comment

by:robhas
ID: 1437800
Here is the code I forgot to add to the last comment.
dbCurrent.Execute "INSERT INTO CATEGORYGROUP IN PPRevenues & Year(Date) - 1 & .mdb select * from [categorygroup];"

Thanks
0
 
LVL 14

Expert Comment

by:waty
ID: 1437801
You should create the query like that :

dbCurrent.Execute "INSERT INTO CATEGORYGROUP IN PPRevenues " & cstr(Year(Date) - 1) & ".mdb select * from [categorygroup];"

0
 

Author Comment

by:robhas
ID: 1437802
It worked great. Thanks for all the help.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question