Ms access DoCmd.TransferDatabase在导入dBase IV表时出现类型不匹配错误
我找到并修改的代码:Ms access DoCmd.TransferDatabase在导入dBase IV表时出现类型不匹配错误,ms-access,import,vba,ms-access-2007,dbase,Ms Access,Import,Vba,Ms Access 2007,Dbase,我找到并修改的代码: 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 =
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
命令上都会出现类型不匹配错误。我添加了一个手表
,并确保所有变量都是正确的。我看不出是什么导致了这次失败
我试图一次导入大约20多个dBase IV文件。我使用Control-G执行,然后运行。Access 2007。调用
TransferDatabase
时缺少ObjectType
参数
DoCmd.TransferDatabase acImport, "dBase IV", _
strTable, acTable, strPathFile, ...
^^^^^^^
此外,TransferDatabase
没有参数hasFieldNames
。有关语法,请参见:
DoCmd.TransferDatabase _
TransferType, _
DatabaseType, _
DatabaseName, _
ObjectType, _
Source, _
Destination, _
StructureOnly, _
StoreLogin)