'======================================================================= ' 函 数:adoLinkTable(strMdbPath, strPWD, strLinkName, strTblName) ' 参数说明:strMdbPath 为要链接的数据库的路径 ' strPWD 为打开数据库的密码 ' strLinkName 为链接表名称 ' strTblName 为链接的表的名称 ' 返 回:True 成功,False 失败 ' 调用举例: ' OK = adoLinkTable("c:\123.mdb", "123", "订单", "订单") ' 作者:朱亦文 ' 日期:2002.11.21 '======================================================================= Public Function adoLinkTable(ByVal strMdbPath As String, _ ByVal strPWD As String, _ ByVal strLinkName As String, _ ByVal strTblName As String) As Boolean On Error Resume Goto errh Dim catDB As ADOX.Catalog Set catDB = New ADOX.Catalog ' 建立一个新的表对象 With tblLink .Properties("Jet OLEDB:Create Link") = True catDB.Tables.Append tblLink ' 添加到库中 adoLinkTable = True errh: |
注:在VBA编辑器中引用"Microsoft ADO Ext. 2.5 for DDL and Security"以及"Microsoft ActiveX Data Objects 2.1/2.5/2.6/2.7 Library"