if you use DAO
VB Code:
Private Sub Command1_Click() Dim db As Database Dim sDBFrom As String Dim sDBTo As String Dim td As TableDef Dim sql As String sDBFrom = "C:\TEST\From.mdb" sDBTo = "C:\TEST\To2.mdb" 'check to see if the database exist. if not create it. If Dir(sDBTo) = "" Then 'database does not exist, make the database Set db = CreateDatabase(sDBTo, dbLangGeneral, dbVersion40) db.Close End If 'open the db where you want to get the data from Set db = OpenDatabase(sDBFrom) 'copy all the tables using SQL and Execute For Each td In db.TableDefs 'make sure that you do not try to create the system tables, 'cause they will already be in the db If UCase(Left(td.Name, 4)) <> "MSYS" Then sql = "SELECT * INTO " & td.Name & " IN '" & sDBTo & "' FROM " & td.Name db.Execute sql End If Next td 'close the db db.Close End Sub




Reply With Quote