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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| Private Sub Connexion_Select_Click()
Dim CONN As ADODB.Connection
Dim requestSA As ADODB.Recordset
Dim intLignes As Integer, intColonnes As Integer
Dim intLig As Integer, intCol As Integer
Set CONN = New ADODB.Connection
Set requestSA = New ADODB.Recordset
Var_Serveur = Forms![Connexion]![Field_Serveur]
Var_Database = Forms![Connexion]![Field_Database]
Var_User = Forms![Connexion]![Field_User]
Var_Password = Forms![Connexion]![Field_Password]
Var_Table = Forms![Connexion]![Field_Table]
CONN.ConnectionString = "DRIVER={PostgreSQL UNICODE};Port=xxx;SERVER=" & Var_Serveur & ";DATABASE=" & Var_Database & ";Uid=" & Var_User & ";Pwd=" & Var_Password & ""
CONN.Open
MsgBox "connexion réussie"
DoCmd.OpenForm "Formulaire1"
If Var_Serveur = "xxxxxxxxxx" Then
If Var_Database = "xxx" Then
requestSA.Open "SELECT * FROM public.""xxx""", CONN
Else: MsgBox "Autre table dans la Production"
End If
ElseIf Var_Serveur = "xxxxxxxxxx" Then
If Var_Database = "xxx" Then
Dim TableDefName As DAO.TableDef
Dim FieldName As String
Dim i As Integer
requestSA.Open "SELECT * FROM public." & Var_Table & "", CONN
For i = 0 To requestSA.Fields.Count
FieldName = requestSA.Fields.Item(0).Name
Forms![Formulaire1]![Field1] = FieldName
Next
Do While (Not requestSA.EOF)
Forms![Formulaire1]![Col1Lig1] = requestSA![user_id]
Forms![Formulaire1]![Col2Lig1] = requestSA![UserName]
Forms![Formulaire1]![Col3Lig1] = requestSA![Password]
Forms![Formulaire1]![Col4Lig1] = requestSA![email]
Forms![Formulaire1]![Col5Lig1] = requestSA![created_on]
Forms![Formulaire1]![Col6Lig1] = requestSA![last_login]
requestSA.MoveNext
Loop
Else: MsgBox "Autre table dans la recette"
End If
Else: MsgBox "Mauvaise sélection"
End If
'requestSA.Close
CONN.Close
End Sub |
Partager