建立一个新的模块,将以下代码复制黏贴到模块中:
'================================
Public Function CheckLinks() As Boolean
Dim DB As Database
Dim tbl As TableDef
Dim a As String
Dim b As String
Dim d As String
Dim dns As String
Set DB = CurrentDb
a = "sa" '数据库用户
b = "sa" '数据库口令
d = "采购订单" '数据库名称
dns = "FILEDSN=采购订单.dsn;UID=" & a & "WD=" & b & ";WSID=;DATABASE=" & d & ";Network=DBMSSOCN"
For Each tbl In DB.TableDefs
If tbl.Attributes = 536870912 Then
tbl.Connect = dns
tbl.Attributes = dbAttachSavePWD
tbl.RefreshLink
End If
Next
DoCmd.OpenForm "SY_系统登录"'你的登录窗口名称
End Function
’==================================
然后建立一个“宏”
'------------------------------------------------------------
' autoexec
'
'------------------------------------------------------------
Function autoexec()
On Error GoTo autoexec_Err
Call CheckLinks
autoexec_Exit:
Exit Function
autoexec_Err:
MsgBox Error$
Resume autoexec_Exit
End Function
‘=========================
宏操作:RunCode
函数名称:CheckLinks ()
宏名:autoexec