[原创]程序一启动就自动链接后台数据库
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'2005-08-18 中俄双雄演义日
'By 狠狠活
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Sub LinkTables(strDatabase As String)
Dim dbs As Database
Dim tdf As TableDef
Dim intI As Integer
Set dbs = CurrentDb
Set tdf = dbs.TableDefs(0)
For intI = 0 To dbs.TableDefs.Count - 1
Set tdf = dbs.TableDefs(intI)
If Len(tdf.Connect) > 0 Then
tdf.Connect = ";DATABASE=" & strDatabase
tdf.RefreshLink
End If
Next intI
End Sub
'调用方法:
Call LinkTables("C:\MyFolder\Mydb.mdb")
--------------------------------------------
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'2005-08-18 中俄双雄演义日
'By 狠狠活
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Sub LinkTables(strDatabase As String)
Dim dbs As Database
Dim tdf As TableDef
Dim intI As Integer
Set dbs = CurrentDb
Set tdf = dbs.TableDefs(0)
For intI = 0 To dbs.TableDefs.Count - 1
Set tdf = dbs.TableDefs(intI)
If Len(tdf.Connect) > 0 Then
tdf.Connect = ";DATABASE=" & strDatabase
tdf.RefreshLink
End If
Next intI
End Sub
'调用方法:
Call LinkTables("C:\MyFolder\Mydb.mdb")
----------------------------------------------------------------------------------------
謝謝﹐還會有提示的。。。。。。C:\MyFolder\Mydb.mdb錯誤路徑。。。。
沒有達到我想要的效果。。。
有別的方法嗎?
好象注釋dll可以嗎?不過不知道控制這個錯誤提示的是哪個dll.
----------------------------------------
[此贴子已经被作者于2006-1-10 12:16:12编辑过]
|