MOVE records from c\ to c:\

User avatar
sal21
PlatinumLounger
Posts: 4357
Joined: 26 Apr 2010, 17:36

MOVE records from c\ to c:\

Post by sal21 »

Have 2 database in C:\ STAT_2016 and STAT_2017.
wth a vb6 code possible to select * from STAT_2016 WHERE anno='2017' and cut and append up STAT_2017?

note:
all database have the same table name

User avatar
HansV
Administrator
Posts: 78512
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: MOVE records from c\ to c:\

Post by HansV »

Open an ADODB connection to the database in STAT_2016. First, execute the following SQL to append the records to the target table:

Code: Select all

    strSQL = "INSERT INTO TableName IN C:\STAT_2017\Database.mdb SELECT TableName.* FROM TableName"
Then execute the following SQL to delete the records from the source table:

Code: Select all

    strSQL = "DELETE TableName.* FROM TableName"
Substitute the correct names and paths.
Best wishes,
Hans