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
|
Function Get_ComboEtat(Tbl As String, Chps As String) As Variant()
Req = "SELECT DISTINCT " & Chps & " FROM [" & Tbl & "]" & _
" ORDER BY " & Chps
Dim d
d = MyQuery(Req, 0)
If TypeName(d) <> "Booleant" Then Get_ComboEtat = d
' Else: Get_ComboEtat = Array("")
End Function
Function Get_Etat(Optional Nm As String = "") As Variant()
Req = "SELECT Champs2, Champs3, Champs4, Champs5, Champs6, Champs7, Champs8, Champs9, Champs10" & _
" FROM [Gestion] "
If Not Nm = "" Then Req = Req & " WHERE Champs3='" & Nm & "'"
Req = Req & " ORDER BY Champs2, Champs3, Champs4, Champs5, Champs6, Champs7, Champs8, Champs9, Champs10"
If Query(Req) > 0 Then Get_Etat = Application.Transpose(Rcd) _
Else Get_Etat = Array("")
End Function
Function MyQuery(Req As String, Optional Head As Byte = 1) As Variant
With CreateObject("ADODB.Connection")
.Provider = "MSDASQL"
.Open "DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=" & BDD
With .Execute(Req)
If Not .EOF Then
MyQuery = .getrows
Else
MyQuery = False
End If
.Close
End With
.Close
End With
End Function |
Partager