superbeast23
asked on
Copying access tables to a central access database
i need to know how to copy, through code, several tables from different access databases scattered over the network to a central access database. i need the tables to be overwritten during the copy operation. i was hoping this could be done through sql. any help is greatly appreciated.
dennis
dennis
Not exact code but to give you the idea
CopyTable ("COMPANY","c:\old.mdb","c :\new.mdb" )
-------------------------- --
Function CopyTable(TableName as string,DataSource as string, DataPathnew as string)
dim conn as adodb.connection
Set Conn = New ADODB.Connection
Conn.Open "Provider=Microsoft.Jet.OL EDB.4.0;" & _
"Data Source=" & DataSource & ";" & _
"User Id=admin;" & _
"Password=;"
conn.execute "Delete * From " & tableName
Ssql = "INSERT INTO " & TableName & _
" IN '" & DataPathNew & "' SELECT " & TableName & ".* From " & TableName
Conn.Execute (Ssql)
conn.close
end Function
CopyTable ("COMPANY","c:\old.mdb","c
--------------------------
Function CopyTable(TableName as string,DataSource as string, DataPathnew as string)
dim conn as adodb.connection
Set Conn = New ADODB.Connection
Conn.Open "Provider=Microsoft.Jet.OL
"Data Source=" & DataSource & ";" & _
"User Id=admin;" & _
"Password=;"
conn.execute "Delete * From " & tableName
Ssql = "INSERT INTO " & TableName & _
" IN '" & DataPathNew & "' SELECT " & TableName & ".* From " & TableName
Conn.Execute (Ssql)
conn.close
end Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i know i didnt specify this in my opening, but is it possible to drop the table before copying the new table? the reason i ask is that it is possible for the structure of the source table to change. what would have to occur is the table with the new structure (i.e. new colums added) would be added to the central database there by deleting the old table. both tables would still be named the same.
http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=697