我正在运行 Access 2016。我正在尝试将查询结果导出到文本文件中,但我不断收到错误 3625 未找到规范。我创建了规范,如果我运行规范,它会按预期工作。我尝试使用引号而不是导出规范,但文件上没有格式。我在网上找到的解决方案是说使用高级选项卡来定义格式,在我的 Access 2016 版本上,规范创建过程中没有高级选项卡。我已经逐步完成了该过程,并且所有目录和文件名都已正确创建。错误发生在以下行:DoCmd.TransferText TransferType:=acExportDelim, SpecificationName:=strExportSpec, TableName:=strQueryName, FileName:=strFullName, HasFieldNames:=True
任何帮助表示赞赏。
Private Sub Export_Click()
Dim strFileName As String
Dim lFileName As Long
Dim strCurrentDate As String
Dim strFormattedDate As String
Dim dtCurrentDate As Date
Dim strDir As String
Dim strFullName As String
Dim strExportSpec As String
Dim strQueryName As String
Dim strYear As String
Dim strMonth As String
Dim strPath1 As String
Dim strPath2 As String
strYear = Format(Date, "yyyy")
strMonth = Format(Date, "mm")
'Check if Directory Year exists
strPath1 = "C:\Users\Owner\Google Drive\Employment\Mass Unemployment\" & strYear
'Check if year exists
If Dir(strPath1, vbDirectory) = "" Then
MkDir strPath1
End If
'Create
strPath2 = "C:\Users\Owner\Google Drive\Employment\Mass Unemployment\" & strYear & "\" & strMonth & "\"
If Dir(strPath2, vbDirectory) = "" Then
MkDir strPath2
End If
strCurrentDate = Date
strFormattedDate = Format(strCurrentDate, "mmddyyyy")
lFileName = InputBox("Enter Week Number", "Enter Week Number")
strFileName = strFormattedDate
strFullName = strPath2 & strFileName & ".txt"
strExportSpec = "Export_Spec" ' error 3625 export spec does not exist
strQueryName = "qryUnEmployment"
DoCmd.TransferText TransferType:=acExportDelim, SpecificationName:=strExportSpec, TableName:=strQueryName, FileName:=strFullName, HasFieldNames:=True
End Sub
我相信 Parfait 告诉您的是保存的导入/保存的导出与导入/导出规范有很大不同。您正在尝试将保存的导出放入需要规范的 TransferText 参数中。您可能在某个时候进行了导出并将这些步骤保存为已保存的导出。
如果您真的对使用此导出的规范感兴趣,那么您将希望通过导入您想要的格式的现有文本文件来创建一个。请参阅上面的冻糕答案。
否则,只需将规范参数留空即可导出查询。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句