troubleshooting Question

TransferSpreadsheet error

Avatar of baldryjames
baldryjames asked on
Microsoft Access
5 Comments1 Solution366 ViewsLast Modified:
I am trying to run a loop of transferspreadsheet commands, this has worked for several months and all of a sudden it's not running.
I get an error message "Unable to close database c:\analysis.xls" followed by invalid databse object reference and runtime error 3276 internal buffer locked by another user.
Can anybody shed some light onto what is going on? It'll get to 200403 and then fall over, everytime without fail.

Here is the code:
Sub RunANAL4()
'C:\Documents and Settings\jamesbald\My Documents\Triangulation\200509
Dim currmnth As String
currmnth = InputBox("Please enter current month in yyyymm format")
If Right(currmnth, 2) > 12 Then
Exit Sub
End If
Analysis4 (currmnth)
End Sub

Function Analysis4(currmnth As String)
Dim mnth As String
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim Query As String

For a = 2003 To Left(currmnth, 4)
c = 12
If a = Left(currmnth, 4) Then c = Right(currmnth, 2)

    For b = 1 To c
    mnth = a & b
    If b <= 9 Then mnth = a & "0" & b
    Query = "CTQ" & mnth
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, Query, "C:\analysis.xls", 1
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, Query & "£", "C:\analysis.xls", 1
    Next b
Next a

End Function
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros