【发布时间】:2017-04-14 14:20:37
【问题描述】:
我有一个导出文件的按钮,但首先它会检查该文件是否存在。如果是,则删除该文件并在其位置写入一个新文件。问题是单击此按钮会立即使数据库崩溃。任何想法为什么?这个问题最近才出现——它之前在 Acess 2013 和 Access 2016 上都运行良好。环境是一个商业环境(公司笔记本电脑,而不是个人笔记本电脑),我们所做的大部分事情都由 IT 管理。管理员。
代码:
Private Sub Command370_Click()
Dim myQueryName As String
Dim myExportFileName As String
myQueryName = "qry_SAP_FGCheck"
myExportFileName = "J:\2017\SAP\SAPExports\DailyFGCheck_Export.xlsx"
If Len(myExportFileName) > 0 Then
On Error GoTo Err_Msg
Kill myExportFileName
End If
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, myQueryName, myExportFileName
Application.FollowHyperlink myExportFileName
Err_Msg: If (Err.Number = 70) Then MsgBox "Error: (" & Err.Number & ")" & Err.description & ". You must close the spreadsheet in order to export.", vbOKOnly Else Resume Next
End Sub
【问题讨论】:
标签: ms-access vba ms-access-2013 ms-access-2016