transferdatabase error

S

Sandy H

Hi
I am using the following code to transfer database objects to a new
database. When the first DoCmd.TransferDatabase line is run, I get a
run-time error 3024 saying that the file can't be found. The file is there
so I'm not sure what is happening. Also, although I check that the database
isn't already there before I create it, I get a 'File already exists' error
when creating the database if it is there. Can anyone please tell me what I
am doing wrong.

Sub CreateNewMDBFile()

Dim ws As Workspace
Dim db As Database
Dim LFilename As String
Dim rs As Recordset
Dim strName As String

'Get default Workspace
Set ws = DBEngine.Workspaces(0)

'Path and file name for new mdb file
LFilename = "C:\NewATIDatabase"

'Make sure there isn't already a file with the name of the new database
If Dir(LFilename) <> "" Then Kill LFilename

'Create a new mdb file
Set db = ws.CreateDatabase(LFilename, dbLangGeneral)
DoEvents

Exporf both table definition and data to new mdb file
DoCmd.TransferDatabase acExport, "Microsoft Access", LFilename, acTable,
"tblMasterDeviceList", "tblMasterDeviceList", False
DoCmd.TransferDatabase acExport, "Microsoft Access", LFilename, acTable,
"tblReports", "tblMasterDeviceList", False
DoCmd.TransferDatabase acExport, "Microsoft Access", LFilename, acTable,
"tblIndex", "tblMasterDeviceList", False

Thanks in advance
Sandy
 
J

John Griffiths

currently you are using
LFilename = "C:\NewATIDatabase"

what happens if
LFilename = "C:\NewATIDatabase.mdb"

Just a thought - John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top