Hey,
Basically the code below, should first create a database and then copy
the tables from one external database to this newly created database.
At the moment I am using a third access database file to perform this
task, (I would code it in VB, but we don't currently own a version).
This code works a treat if you copy the CurrentDB where the code is
running to a new database, but I need the code to access another
database, the code I have used is below. As you can see I have
replaced the CurrentDB with the necessary path name. The error I get
though is...
The Microsoft Jet database engine could not find the object
'TableNameInHer e'. Make sure the object exists and that you spell its
name and the path name correctly.
I understand the problem but as it works using CurrentDB i'm stuck Any
help is greatly appreciated,
Cheers
Sam
Code Is here
Sub sExport(strDBNa me As String)
On Error GoTo E_Handle
Dim db As DAO.Database
Dim tdf As DAO.TableDef
If Dir(strDBName) <> "" Then Kill strDBName
Set db = DBEngine(0).Cre ateDatabase(str DBName, dbLangGeneral)
db.Close
Set db = DBEngine.OpenDa tabase("C:\Docu ments and
Settings\SSh\De sktop\Copy of Crack2.mdb")
For Each tdf In db.TableDefs
If Left(tdf.Name, 4) <> "MSys" Then
DoCmd.TransferD atabase acExport, "Microsoft Access",
strDBName, acTable, tdf.Name, tdf.Name
End If
Next tdf
MsgBox "Tables copied OK", vbOKOnly, " "
sExit:
Set db = Nothing
Exit Sub
E_Handle:
MsgBox Err.Description , vbOKOnly, Err.Number
Resume sExit
End Sub
Basically the code below, should first create a database and then copy
the tables from one external database to this newly created database.
At the moment I am using a third access database file to perform this
task, (I would code it in VB, but we don't currently own a version).
This code works a treat if you copy the CurrentDB where the code is
running to a new database, but I need the code to access another
database, the code I have used is below. As you can see I have
replaced the CurrentDB with the necessary path name. The error I get
though is...
The Microsoft Jet database engine could not find the object
'TableNameInHer e'. Make sure the object exists and that you spell its
name and the path name correctly.
I understand the problem but as it works using CurrentDB i'm stuck Any
help is greatly appreciated,
Cheers
Sam
Code Is here
Sub sExport(strDBNa me As String)
On Error GoTo E_Handle
Dim db As DAO.Database
Dim tdf As DAO.TableDef
If Dir(strDBName) <> "" Then Kill strDBName
Set db = DBEngine(0).Cre ateDatabase(str DBName, dbLangGeneral)
db.Close
Set db = DBEngine.OpenDa tabase("C:\Docu ments and
Settings\SSh\De sktop\Copy of Crack2.mdb")
For Each tdf In db.TableDefs
If Left(tdf.Name, 4) <> "MSys" Then
DoCmd.TransferD atabase acExport, "Microsoft Access",
strDBName, acTable, tdf.Name, tdf.Name
End If
Next tdf
MsgBox "Tables copied OK", vbOKOnly, " "
sExit:
Set db = Nothing
Exit Sub
E_Handle:
MsgBox Err.Description , vbOKOnly, Err.Number
Resume sExit
End Sub
Comment