我尝试使用下面的代码将多个csvs导入到一个表中。由于某些原因,它导入所有csvs,但为每个csvs创建单独的表,而不是导入到UKR表中。
我使用的是Access 2016,而UKR是一个没有字段名称或数据的空白表。
有没有人知道问题出在哪里?
谢谢
Option Compare Database
Option Explicit
Function DoImport()
Dim strPathFile As String
Dim strFile As String
Dim strPath As String
Dim strTable As String
Dim blnHasFieldNames As Boolean
blnHasFieldNames = True
strPath = "C:\UKR\"
strTable = "UKR"
strFile = Dir(strPath & "*.csv")
Do While Len(strFile) > 0
strTable = Left(strFile, Len(strFile) - 4)
strPathFile = strPath & strFile
DoCmd.TransferText acImportDelim, , strTable, strPathFile, blnHasFieldNames
strFile = Dir()
Loop
MsgBox "done"
End Function发布于 2020-06-09 18:26:20
因为代码正在重置循环中的目标表。删除行
strTable = Left(strFile, Len(strFile) - 4)
https://stackoverflow.com/questions/62279253
复制相似问题