Export Access2K table to another database

T

Tamer

Hi all,
I'm new to the DAO world. Please excuse my limited
knowledge on this.
I'm trying to export a table in an access2k database to
another database form OnClose event procedure of a form,
the way that everytime the form closes, it's underlying
table will be exported to the other database and overwrite
the old table . I used the following code:-

Dim ws As DAO.Workspace
Dim db1 As DAO.Database
Set ws = DBEngine.Workspaces(0)
Set db1 = ws.OpenDatabase("M:\FileName.mdb")
DoCmd.TransferDatabase acLink, "Microsoft Access", _
"M:\SASS2K.mdb", acTable, "Table1", db1

The code returns an error "Run-time error 3024. Could not
find file" in the line of Set db1=
I'm sure the path is correct. Please help
 
P

Phil Hunt

I used this myself. You may want to try it:


Set DB = DBEngine.OpenDatabase(c:\currentDB.mdb, , True)
DBEngine.BeginTrans
SQL = "SELECT INTO NewTable IN 'c:\NEWDB.mdb' FROM thisTable"
Call DB.Execute(SQL, dbFailOnError)
DBEngine.CommitTrans
DB.Close
 
G

Guest

This still didn't work. It's funny, because after dealing with that
error, and rerunning the query, it does find the databse it just
created. I had guessed that when it creates the db, it takes some
time before the dbEngine could find that file.
 
P

Paul Johnson

I didn't try running your code, but at a quick glance, it looks like you're
missing an asterisk in your SQL statement:
"SELECT * INTO NewTable "(etc.)

HTH,

Paul Johnson
 

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

Top