运行时错误'3073':操作必须使用可更新的查询

时间:2014-02-14 15:06:40

标签: vba export access-vba runtime-error ms-access-2000

我有一些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为here

1 个答案:

答案 0 :(得分:1)

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