Solved

Move data between databases

Posted on 1998-10-02
8
121 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 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

728 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