【发布时间】:2014-06-16 21:22:23
【问题描述】:
我找到并修改的代码:
Option Compare Database
Option Explicit
Sub DoImport()
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String
Dim blnHasFieldNames As Boolean
blnHasFieldNames = True
strPath = "C:\mypath\"
strFile = Dir(strPath & "*.dbf")
Do While Len(strFile) > 0
strPathFile = strPath & strFile
strTable = Left(strFile, Len(strFile) - 4)
DoCmd.TransferDatabase acImport, "dBase IV", _
strTable, strPathFile, blnHasFieldNames
strFile = Dir()
Loop
End Sub
每次在DoCmd.TransferDatabase 命令上都会出现类型不匹配错误。我添加了Watch,并确保所有变量都正确。我看不出是什么导致了这个失败。
我正在尝试一次导入大约 20 多个 dBase IV 文件。我正在使用 Control-G 执行然后运行。访问 2007。
【问题讨论】:
标签: ms-access import vba ms-access-2007 dbase