Function MyTrdb(Fname As String)
'功能:重建表链接。
'参数:Fname:后台数据库完整文件名
'示例:MyTrdb(CurrentProject.Path & "\后台数据库.mdb")
Dim obj As AccessObject, dbs As Object
Dim tbnmae As String
On Error GoTo MyTrdb_Err
Set dbs = Application.CurrentData
For Each obj In dbs.AllTables
tbnmae = obj.Name
If InStr(obj.Name, "MSys") = 0 Then
DoCmd.DeleteObject acTable,tbnmae '删除链接
DoCmd.TransferDatabase acLink, "Microsoft Access", Fname, acTable, tbnmae, tbnmae, False '建立链接
End If
Next obj
MyTrdb_Exit:
Exit Function
MyTrdb_Err:
MsgBox Error$
Resume MyTrdb_Exit
End Function