KatsyBLB
asked on
DoCmd.TransferSpreadsheet Causes Err#3027 Cannot Update. Database or Object is read-only.
One of my jobs is to make XL spreadsheets from Access data...we have recently gone to Access2000. I will type below an abbreviated form of my code. When running the code, about 2/3 of the XL sheets are created and the others are not. During the run, I get error code 3027 when it hits the DoCmd.TransferSpreadsheet line. I solved it for now by changing the "save to" directory from a desktop folder to the desktop. Ideas, anyone? I will paste below an abbreviated form of the code.
Option Compare Database
Option Explicit
Dim adThisDB As DAO.Database
Dim adRecSet1 As DAO.Recordset, adRecSet2 As DAO.Recordset
Dim adQueryDef As DAO.QueryDef
Dim strSQL1 As String, strSQL2 As String
Dim strParameter1 As String
Const strEmailDir = "C:\WINDOWS\Desktop\Folder X\"
Const strQuery = "qXX"
Private Sub SaveXL()
Set adThisDB = CurrentDb
strSQL1 = "SELECT FieldX FROM TableX GROUP BY FieldX"
Set adRecSet1 = adThisDB.OpenRecordset(str SQL1, dbOpenSnapshot)
adRecSet1.MoveLast
adRecSet1.MoveFirst
strParameter1 = adRecSet1.Fields(0)
Set adQueryDef = adThisDB.QueryDefs(strQuer y)
strSQL2 = "SELECT , , , , FROM [TableX] WHERE [TableX].[FieldX]= '" & strParameter1 & "' "
adQueryDef.SQL = strSQL2
Do While Not adRecSet1.EOF
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, strQuery, strEmailDir & strParameter1 & ".xls", True
adRecSet1.MoveNext
strParameter1 = adRecSet1.Fields(0)
strSQL2 = "SELECT , , , , FROM [TableX] WHERE [TableX].[FieldX]= '" & strParameter1 & "' "
adQueryDef.SQL = strSQL2
Loop
Clean up here...close and set to nothing
End Sub
Any help or ideas will be greatly appreciated.
Barbara
Option Compare Database
Option Explicit
Dim adThisDB As DAO.Database
Dim adRecSet1 As DAO.Recordset, adRecSet2 As DAO.Recordset
Dim adQueryDef As DAO.QueryDef
Dim strSQL1 As String, strSQL2 As String
Dim strParameter1 As String
Const strEmailDir = "C:\WINDOWS\Desktop\Folder
Const strQuery = "qXX"
Private Sub SaveXL()
Set adThisDB = CurrentDb
strSQL1 = "SELECT FieldX FROM TableX GROUP BY FieldX"
Set adRecSet1 = adThisDB.OpenRecordset(str
adRecSet1.MoveLast
adRecSet1.MoveFirst
strParameter1 = adRecSet1.Fields(0)
Set adQueryDef = adThisDB.QueryDefs(strQuer
strSQL2 = "SELECT , , , , FROM [TableX] WHERE [TableX].[FieldX]= '" & strParameter1 & "' "
adQueryDef.SQL = strSQL2
Do While Not adRecSet1.EOF
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, strQuery, strEmailDir & strParameter1 & ".xls", True
adRecSet1.MoveNext
strParameter1 = adRecSet1.Fields(0)
strSQL2 = "SELECT , , , , FROM [TableX] WHERE [TableX].[FieldX]= '" & strParameter1 & "' "
adQueryDef.SQL = strSQL2
Loop
Clean up here...close and set to nothing
End Sub
Any help or ideas will be greatly appreciated.
Barbara
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Could be the long-filename thing, were it won't work if the folder is over 8 characters.
ASKER
Just tested again...it doesn't like any folder names that are more than 5 characters long, i.e., it worked when I named the folder "Fold" or "Folde" but not when I named it "Folder."
Yeah, I think it depends on the Operating System or file system. Looks like that's ur problem.
Well that doesn't make any sense. I'll look in the Knowledge base to see if it comes up.
ASKER
Found in MS Knowledge Base:
http://support.microsoft.com/support/kb/articles/Q250/4/59.ASP
This is a bug that MS is addressing. According to the article "You receive this error message no matter which file format you are exporting to." CAUSE is noted as "The length of the path...exceeds 64 characters."
However, you'll notice that my path length could not exceed 24 characters (e.g., "C:\WINDOWS\Desktop\Folde" ) before problems started.
http://support.microsoft.com/support/kb/articles/Q250/4/59.ASP
This is a bug that MS is addressing. According to the article "You receive this error message no matter which file format you are exporting to." CAUSE is noted as "The length of the path...exceeds 64 characters."
However, you'll notice that my path length could not exceed 24 characters (e.g., "C:\WINDOWS\Desktop\Folde"
Yeah I saw that too but you didn't exceed the 64 characters.
Got me on this one.
Got me on this one.
This question appears to have been abandoned. A question regarding will be left in the Community Support area regarding its disposition; if you have any comment about the question, please leave it there.
The recommendation will be to accept the comment of PunisherDude.
The link to the Community Support area is:
https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
DO NOT ACCEPT THIS COMMENT AS AN ANSWER.
Regards,
ep
The recommendation will be to accept the comment of PunisherDude.
The link to the Community Support area is:
https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
DO NOT ACCEPT THIS COMMENT AS AN ANSWER.
Regards,
ep
ASKER