Link to home
Start Free TrialLog in
Avatar of superbeast23
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
Avatar of SweatCoder
SweatCoder
Flag of United States of America image

sql would be best, but i have an adox solution if you need it:

http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=697
Avatar of MrPan
MrPan

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.OLEDB.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
ASKER CERTIFIED SOLUTION
Avatar of MrPan
MrPan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of superbeast23

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.