部署访问前端后重新链接表

时间:2016-01-20 17:52:38

标签: database vba ms-access

我最近刚将数据库拆分为前端和后端。我正在通过电子邮件将前端部署到用户。他们将前端粘贴到他们的DeskTop上。我想在加载函数中包含代码,该代码将自动重新链接表,以便表的相对路径反映它们到后端的映射。我使用的代码生成以下错误:

3170 Run Time Error.  Could not find installable ISAM. 

以下是代码:

Public Function RefreshLinks(strFilename As String) As Boolean
  ' Refresh table links to a backend database - strFilename (full path)
  ' Returns True if successful.
  Dim dbs As Database
  Dim tdf As TableDef

  ' Loop through all tables in the database.
  Set dbs = CurrentDb
  For Each tdf In dbs.TableDefs
    MsgBox " The table is " & tdf.name
    ' If the table has a connect string, it's a linked table.
    If Len(tdf.Connect) > 0 Then
      MsgBox "The table has a connect string."

      tdf.Connect = ";DATABASE= " & strFilename
      tdf.Connect = strFilename
      tdf.RefreshLink ' Relink the table.
      Err = 0
      On Error Resume Next
      tdf.RefreshLink ' Relink the table.
      'MsgBox "The Table is linked"

      If Err <> 0 Then
        RefreshLinks = False
        ' MsgBox "The tables aren't refreshed"
        Exit Function
      End If
    End If
  Next tdf

  RefreshLinks = True ' Relinking complete.
  'MsgBox "The tables are refreshed"
End Function

传递的文件名是EASDBLocation = "\\RSDATA\RS2\Data2\ComplianceReviews\BusinessReviews\ReviewDatabase\2014 Revised Database\Archive\RAS Database Split Test_be.mdb"

0 个答案:

没有答案