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

July 30th, 2008 - 05:13 pm ET by EagleOne | Report spam
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
email Follow the discussionReplies 2 repliesReplies Make a reply

Similar topics

Replies

#1 Douglas J. Steele
July 30th, 2008 - 08:31 pm ET | Report spam
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
http://I.Am/DougSteele
(no private e-mails, please)


wrote in message
news:
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


Replies Reply to this message
#2 EagleOne
July 31st, 2008 - 07:04 am ET | Report spam
Excellent and Complete answer.


"Douglas J. Steele" wrote:

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
http://I.Am/DougSteele
(no private e-mails, please)


wrote in message
news:
> 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





email Follow the discussion Replies Reply to this message
Help Create a new topicReplies Make a reply
Search Make your own search