TransferSpreadsheet (via VBA) getting : "Read Only" error message

  • Thread starter EagleOne@microsoftdiscussiongroups
  • Start date
E

EagleOne@microsoftdiscussiongroups

2003

From Tools.mdb where the controlling VBA module is being run, another
instance of Access was created for Recon.mdb

Several procedures have worked fine prior to this point.

It is when I attempt to DoCmd.TransferSpreadsheet ..... that an error occurs.

SETUP:

'Up to this point Tools.mdb has been the Currentdb
'
'
dbsfilename = "Recon.mdb"
Set appAccess = CreateObject("Access.Application")
appAccess.NewCurrentDatabase myPath & dbsfilename
Set dBs = appAccess.CurrentDb
' Next works fine
dBs.Execute "SELECT * INTO STARSData FROM _
[Text;FMT=Fixed;HDR=No;DATABASE=" _
& myPath & ";].[STARSData#txt];", dbFailOnError
' Next works fine
dBs.Execute "SELECT * INTO CHOOSEData FROM _
[Text;FMT=Delimited;HDR=No;DATABASE=" _
& myPath & ";].[CHOOSEData#txt];", dbFailOnError
' Next "With" series of commands work fine
With dBs
.Execute "ALTER TABLE CHOOSEData ADD COLUMN LTrim_BFY VarChar(5);"
.Execute "ALTER TABLE CHOOSEData ADD COLUMN LTrim_AAA VarChar(7);"
.Execute "ALTER TABLE CHOOSEData ADD COLUMN LTrim_REG VarChar(5);"
......
......
End With
' At this point the Currentdb.name is Tools.mdb
' At this point the dBs.name is Recon.mdb

' Now the challenge!!

' I wish to do a Transfer Spreadsheet from Recon.mdb
' Recon.mdb is not my currentdb (Tools.mdb is the currentdb)
' dbs.name is Recon.mdb (this is the file from which I wish the
' Transferspreadsheet to act upon!!!!)
' Therefore, since Recon.mdb is NOT my currentdb, I get "the file is
read only"
' error when I issue the following command:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, _
"STARS_UMD", myPath & STARSfilename & ".xls, True"

How can I either:
1) make Recon.mdb my currentdb (If possible and appropriate)
2) what VBA/SQL code could I use to effect the "TransferSpreadSheet"
from Recon.mdb (if Tools.mdb is still my currentdb?)

Any help thoughts greatly appreciated!

PS: I have attempted to close Recon.mdb; have done so; yet I still get an
error.

The code I used to close:
appAccess.CloseCurrentDatabase
dBs.Close
Set appAccess = Nothing


Bottom line - at this point in the VBA code, I am complete with Tools.mdb
(except closing when the VBA subroutine completes) but I still wish to copy
two tables in Recon.mdb to excel files - then all files can be closed
 

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