【发布时间】:2014-02-14 15:06:39
【问题描述】:
我有一些 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
【问题讨论】:
-
TransferType acExport,可能需要是以下msdn.microsoft.com/en-us/library/office/ff194227.aspx 之一。您的查询看起来像一个选择,所以我认为该错误可能是误报。
-
看来我是个白痴。我尝试了 WORD acExport,我需要与 acExportDelimited 对应的数字。提交为答案,我会标记你
-
谢谢!在你的辩护中,这是一个糟糕的错误,我以前也遇到过。
标签: vba ms-access export runtime-error ms-access-2000