[vb]代码库
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