TransferDatabase

K

Kitty

I am trying to use code to transfer a table from an
external database into the current database. Both are
Access databases.

This is the code I'm using...

DoCmd.TransferDatabase _
TransferType:=acImport, _
DatabaseType:="Microsoft Access", _
DatabaseName:=TransferDrive, _
ObjectType:=acTable, _
Source:="tblSample"

Where TransferDrive is the path and name of the database.
The actual name of the database is always the same; the
path may differ which is why I'm using a variable. I've
dried feeding just the drive as a variable with & to add
it to the database name, and that errors out as well.

With this code, I receive this error - The object name "
you entered doesn't follow Microsoft Office Access object-
naming rules.

TransferDrive is dimmed as a string, so shows "" around it
when I put my cursor on the field.

Thanks for your help.

Kitty
 
G

Guest

-----Original Message-----
I am trying to use code to transfer a table from an
external database into the current database. Both are
Access databases.

This is the code I'm using...

DoCmd.TransferDatabase _
TransferType:=acImport, _
DatabaseType:="Microsoft Access", _
DatabaseName:=TransferDrive, _
ObjectType:=acTable, _
Source:="tblSample"


All you need to do is also add a Destination.

i.e.

DoCmd.TransferDatabase _
TransferType:=acImport, _
DatabaseType:="Microsoft Access", _
DatabaseName:=TransferDrive, _
ObjectType:=acTable, _
Source:="tblSample",
Destination:="tblSample"

You can keep the name same if you like, or change it.
 
G

Guest

Thanks. I had to take out the TransferType line - it
would error that it was already defined. Strange, but it
works, so that's what matters.

Kitty
 

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