似乎在网上的任何地方都找不到这个答案,所以我们开始吧。
我有一些代码可以提取一个 excel 文件并将其数据输入到 MS Access 2007 中的表中。
如何验证文件是否已成功导入?
例如:
If excel did import Then
MsgBox "Import successful"
Else If Excel didnt import
MsgBox "Import Not successful"
我目前正在使用以下代码导入 excel 文件:
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tblData", "FilePath", True, "Sheet1!"
谢谢
最佳答案
看了一圈终于明白了!
将此代码放在“DoCmd.TransferSpreadsheet”代码之后。
If DBEngine.Errors.Count = 0 Then
MsgBox "Imported data successfully!"
ElseIf DBEngine.Errors.Count > 0 Then
MsgBox "The file did not import!"
Exit Sub
End If
关于vba - 如何验证 Excel 文件是否已成功导入 MS Access?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15201540/