Importin a Table

  • Thread starter Thread starter Stephen Rockower
  • Start date Start date
S

Stephen Rockower

I am trying to import a table from one database to another (not link). I am
using the following code:

DoCmd.TransferDatabase acImport, , "C:\Documents and
Settings\MyName\Desktop\NewPats.mdb", acTable, "Demogbackup", "NewPats"

but it is not working. What am I doing wrong? Is TransferDatabase the
correct command to use?

Thanks
 
Gee Stephen, "...is not working..." is just a tiny bit vague.

It goes through the motions and nothing happens? You get an error message?
What?

I'm going to make a wild guess and say that you're getting error 2507. Yes?

Although help says that the second argument defaults to "Microsoft Access",
you need to include it.

Other than that, your code is just fine.

Make your line read:

DoCmd.TransferDatabase acImport, "Microsoft Access", _
"C:\Documents and Settings\MyName\Desktop\NewPats.mdb", _
acTable, "Demogbackup", "NewPats"

As long as your "NewPats.mdb" database has a table called "Demogbackup", you
should get a table called "NewPats" in the database where this code is
running.

Before you get too deep into using Access, I'd like to suggest downloading
the naming conventions at http://www.xoc.net/standards/rvbanc.asp and get
into the habit of using them. You'll thank yourself later the longer you use
Access.

Good luck.

Sco
 
Sco,
Sorry about the vagueness... I was writing the question from home, but the
work was at the office, so I didn't remember the actual error. And, yes,
the "Demogbackup" table is in the NewPats database, and I'm trying to create
a new table in my current database called "NewPats". I agree that naming
conventions are more useful. I'll try to be more diligent in the future. I
probably use them 30% of the time though... Since I'm programming only for
myself, I haven't gotten too confused, but I understand the concept,
especially here.

Thanks again.

Steve
 
Stephen,

You addressed everything except whether my suggestion worked.

Sidebar: I'm more diligent using naming conventions when I program for
myself! :-)

Sco
 
Of course it worked! <g>
Thanks again!
Steve
M.L. Sco Scofield said:
Stephen,

You addressed everything except whether my suggestion worked.

Sidebar: I'm more diligent using naming conventions when I program for
myself! :-)

Sco

future.
 
Back
Top