Function Check_SDSN()
' 查看我们要的系统数据源(DSN)是否存在。
' 如果存在,正好;否则,我们就创建一个。
Dim lngKeyHandle As Long
Dim lngResult As Long
Dim lngCurIdx As Long
Dim strvalue As String
Dim classvalue As String
Dim timevalue As String
Dim lngvalueLen As Long
Dim classlngvalueLen As Long
Dim lngData As Long
Dim lngDataLen As Long
Dim strResult As String
Dim DSNfound As Long
Dim syscmdresult As Long
syscmdresult = SysCmd(acSysCmdSetStatus, "查找系统DSN: " & JDS_DSN_name & " ...")
Dim db As Database
Dim tbl As TableDef
Set db = CurrentDb
For Each tbl In db.TableDefs
If tbl.Attributes = 536870912 Then
tbl.Connect =
"DSN=TLC;UID=SAWD=123456;WSID=;DATABASE=ABC;Network=WORKGROUP"
tbl.RefreshLink
End If
Next
End If
End If
Loop While lngResult = ERROR_SUCCESS And Not DSNfound
Call RegCloseKey(lngKeyHandle)
If Not DSNfound Then
MsgBox "请先创建ODBC数据源!", vbInformation, "提示"
DoCmd.OpenForm "系统注册"
Exit Function
Else
DoCmd.Close , , acSaveYes
DoCmd.OpenForm "主界面"
End If
syscmdresult = SysCmd(acSysCmdClearStatus)
Check_SDSN = 0
End Function