Public Sub linktable(strdb As String, strrodb As String, strcn As String, strtdf As String, linktdfname As String)
Dim linktdf As New TableDef
Set dbs = OpenDatabase(strdb)
linktdf.name = linktdfname
100
temptable = UCase(linktdf.name)
For i = 0 To dbs.TableDefs.COUNT - 1
If UCase(dbs.TableDefs(i).name) = temptable Then
If MsgBox(linktdfname + " 已存在,是否删除 ?", vbQuestion + vbYesNo) = vbYes Then
dbs.TableDefs.Delete linktdf.name
Exit For
Else: MsgBox " 重新输入新表名"
linktdfname = InputBox(" 新表名")
GoTo 100
End If
End If
Next i
Set linktdf = dbs.CreateTableDef(linktdfname) ' 链接远程表
linktdf.Connect = ";database=" + strcn
linktdf.SourceTableName = strtdf
dbs.TableDefs.Append linktdf
End Sub