[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Move data between databases

Posted on 1998-10-02
8
Medium Priority
?
123 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 14

Accepted Solution

by:
waty earned 600 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

650 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