0

我有一些 vba 代码,我试图用它来导出查询结果,每次我的代码尝试导出它都会抛出一个错误,Run-time error '3073': Operation must use an updateable query我不知道为什么。即使使用相同的规范,导出其他表和查询也可以正常工作。关于我遇到什么样的问题的任何想法?单步执行确认它碰到问题就DoCmd.TransferText行了

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

我不认为是查询本身,因为右键单击导出具有相同规范的查询就可以了,但是访问查询生成的SQL在这里

4

1 回答 1

1

TransferType acExport 可能需要是以下 msdn.microsoft.com/en-us/library/office/ff194227.aspx 之一。您的查询看起来像一个选择,所以我认为该错误可能是误报。

于 2014-02-14T15:42:36.763 回答