Help with VBA "DoCmd.TransferSpreadsheet acImport ......."

E

EagleOne

2003

I would like the data imported into a table in a non-current() database.

DoCmd.TransferSpreadsheet acImport, , strTableName, myPath & strTableName & ".xls", True
(The above command works but .... I want the data to go to strTableName in another database]

Any coding help appreciated

TIA EagleOne
 
D

Douglas J. Steele

You need to instantiate another instance of Access, set its CurrentDatabase
appropriately, and then do your import. Something like the following
untested air-code:

Dim appAccess As Access.Application

Set appAccess = New Access.Application
appAccess.OpenCurrentDatabase "C:\Folder\File.mdb"
appAccess.DoCmd.TransferSpreadsheet acImport, , strTableName, myPath &
strTableName & ".xls", True
appAccess.CloseCurrentDatabase
Set appAccess = Nothing
 
E

EagleOne@microsoftdiscussiongroups

Excellent and Complete answer.


Douglas J. Steele said:
You need to instantiate another instance of Access, set its CurrentDatabase
appropriately, and then do your import. Something like the following
untested air-code:

Dim appAccess As Access.Application

Set appAccess = New Access.Application
appAccess.OpenCurrentDatabase "C:\Folder\File.mdb"
appAccess.DoCmd.TransferSpreadsheet acImport, , strTableName, myPath &
strTableName & ".xls", True
appAccess.CloseCurrentDatabase
Set appAccess = Nothing

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


2003

I would like the data imported into a table in a non-current() database.

DoCmd.TransferSpreadsheet acImport, , strTableName, myPath & strTableName
& ".xls", True
(The above command works but .... I want the data to go to strTableName in
another database]

Any coding help appreciated

TIA EagleOne
 

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