Public Function ReLink(ByVal strName As String, ByVal strPath As String, ByVal strPWD) As Boolean
Dim dbs As Database
Dim tdf As TableDef, i As Variant
On Error GoTo ErrorHandler
ReLink = False
Set dbs = CurrentDb
For Each i In Application.CurrentData.AllTables '历遍的有表
If DCount("*", "MSysObjects", "[Name]='" & i.Name & "' And [Type]=6") > 0 Then
'判断只有链接表才运行以下代码
strName = i.Name
Set tdf = dbs.TableDefs(strName)
tdf.Connect = "WD=" & strPWD & ";database=" & strPath
tdf.RefreshLink