Solved

Move data between databases

Posted on 1998-10-02
8
114 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
Comment Utility
DB.Execute "Delete from Customers"

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

Author Comment

by:robhas
Comment Utility
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
Comment Utility
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
 

Author Comment

by:robhas
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 14

Expert Comment

by:waty
Comment Utility
Post your code, I will check
0
 

Author Comment

by:robhas
Comment Utility
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
Comment Utility
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
Comment Utility
It worked great. Thanks for all the help.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now