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
| Private Sub Report_Open(Cancel As Integer)
Dim strconn As String
txtdu.Caption = Format(Forms![choixdate]![depuis], dbDate)
txtau.Caption = Format(Forms![choixdate]![jusqua], dbDate)
'strconn = "ODBC;DRIVER=iSeries Access ODBC driver;SERVER=LV011;DATABASE=FGE50C2;UID=CIOCS;PWD=sorfra08;OPTION=3"
Dim oCnMySQL As ADODB.Connection, rs As ADODB.Recordset
Set rs = New ADODB.Recordset
' Connexion à base MySQL
' Crée objet Connection
Set oCnMySQL = New ADODB.Connection
' Définit chaîne de connexion
' * Le provider MSDASQL (ODBC) étant celui par défaut, on peut l'omettre
oCnMySQL.ConnectionString = "ODBC;Driver=CWBODBC;" & _
"DSN=infolog C2;" & _
"UID=CIOCS;PWD=sorfra08;"
' Ouvre la connexion
oCnMySQL.Open
If oCnMySQL Is Nothing Then
MsgBox "connexion non établie !"
End If
'strconn = "select * from gehpro1 where dathis = '20090320'"
strconn = "SELECT dathis, sum(uvcrec) AS uvcrec, sum(stkuvc) as stkuvc, " & _
"(SELECT sum(uvcsrv) AS uvcsrv FROM GEHACT where dathis=gehpro1.dathis) as uvcsrv, " & _
"sum(uvcliv1+uvcliv2+uvcliv3+uvcliv4+uvcliv5) AS uvcliv " & _
"FROM GEHPRO1 where dathis>='20090101' group by dathis order by dathis desc"
' Ouvrir recordset sur table fournisseurs
MsgBox strconn
rs.Open strconn, oCnMySQL, adOpenStatic, adLockReadOnly
'While Not rs.EOF
' MsgBox rs.Fields("dathis")
' rs.MoveNext
'Wend
'Me.RecordSource = strconn
MsgBox "nombre de champs de la requête : " & rs.Fields.Count
'Me.RecordSource = strconn
'Me.totrec = rs.Fields("uvcliv").Value
Me.UVCLIV.ControlSource = rs.Fields(4).Name
Me.UVCREC.ControlSource = rs.Fields(0).Name
'oCnMySQL.Close
'Set rs = Nothing
'Set oCnMySQL = Nothing
End Sub |
Partager