1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
Function fInitialiser()
Dim objCurrent As Object
Set objCurrent = Application.CurrentProject
MsgBox "The current base connection is " & objCurrent.Connection
' On regarde machine pour adapter chaine connexion. Si MachineName <> DSN, on change.
' Table dbo_TrParam en premier
' On regarde la chaine de connexion courante. Si <> pour la machine, on remplace
Set db = CurrentDB
Dim MachineName As String
MachineName = Environ("COMPUTERNAME")
Set td = db.TableDefs("dbo_TrParam")
Dim strCurrentConn As String
strCurrentConn = td.Connect
iPos = InStr(1, strCurrentConn, "UID")
strProfil = Mid(strCurrentConn, iPos + 4, 2)
Dim strConn As String
If (strProfil <> MachineName) Then
strConn = "ODBC;DSN=" & MachineName & ";DATABASE=IFCT-1103;UID=" & MachineName & ""
For Each td In db.TableDefs
If ((td.Attributes And dbSystemObject) = 0) Then
If (InStr(td.Name, "dbo_")) Then
td.Connect = strConn
td.RefreshLink
End If
End If
Next td
End If
' récupérer login ODBC ICI. Le PROMPT se déclenche ici
DoCmd.OpenForm ("@FORM-1103")
DoCmd.RunCommand acCmdAppMaximize
End Function |
Partager