문제

I have some vba code that I am trying to use to export the results of a query,and every time my code tries to export It throws me an error, Run-time error '3073': Operation must use an updateable query, and I'm not sure why. exporting other tables and queries works fine, even with the same spec. Any Ideas on what kind of problem I'm hitting? Stepping through confirms that it hits the problem on the DoCmd.TransferText line

Public Function exportJobDetailRecs(dateStr As String)
'Docmd.TransferText(acexport,specName,TableName, FileName,HasfieldNames,HTMLTableName)
    Set fso = CreateObject("Scripting.FileSystemObject")
    If Not fso.FileExists(directory + CStr(dateStr + "_OrderStatus_jobdets.txt")) Then
        Set temp = fso.createTextFile(directory + CStr(dateStr + "_OrderStatus_jobdets.txt"))
        temp.Close
    Else
        MsgBox "It looks like you have already run the report (or partially run the report) today. Please Remove all remnants of the text output files and re-run." + vbNewLine + directory + CStr(dateStr + "_OrderStatus_jobdets.txt"), vbOKOnly, "Previously Run exports"
        Exit Function
    End If
    Dim fnameStr As String
    fnameStr = CStr(dateStr + "_OrderStatus_jobdets.txt")
    DoCmd.TransferText acExport, _
                        "JobDetail", _
                        "2_JobDetail", _
                        directory + fnameStr

    exportJobDetailRecs = fnameStr
End Function

I dont think it's the query itself, because right-click exporting the query with the same spec works just fine, but the SQL generated by the access query is here

도움이 되었습니까?

해결책

The TransferType acExport, may need to be one of the following msdn.microsoft.com/en-us/library/office/ff194227.aspx. Your query looks like a select, so I think that error may be a false positive.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top