【问题标题】:DoCmd.TransferDatabase gives a Type Mismatch error importing dBase IV tablesDoCmd.TransferDatabase 在导入 dBase IV 表时出现类型不匹配错误
【发布时间】: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


    【解决方案1】:

    您在TransferDatabase 调用中缺少ObjectType 参数。

    DoCmd.TransferDatabase acImport, "dBase IV", _
        strTable, acTable, strPathFile, ...
                  ^^^^^^^
    

    另外,TransferDatabase 没有参数hasFieldNames。语法见DoCmd.TransferDatabase Method (Access)

    DoCmd.TransferDatabase _
        TransferType, _
        DatabaseType, _
        DatabaseName, _
        ObjectType, _
        Source, _
        Destination, _
        StructureOnly, _
        StoreLogin)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-23
      • 1970-01-01
      • 2021-05-11
      • 1970-01-01
      • 2013-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多