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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
| Option Compare Database
Private Sub cmbClients_AfterUpdate()
Dim strSQL As String
Dim strCategory As String
'Initialisation de la variable au contenu de la liste
strCategory = Me!cmbClients.Text
'Initialisation de la chaîne SQL
strSQL = "SELECT [Client_1], Sum([mois1]) AS [janvier]," & _
"Sum([mois2]) AS [février],Sum([mois3]) AS [Mars],Sum([mois4]) AS [avril],Sum([mois5]) AS [mai],Sum([mois6]) AS [Juin],Sum([mois7]) AS [Juillet],Sum([mois8]) AS [Août],Sum([mois9]) AS [Septembre],Sum([mois10]) AS [ctobre],Sum([mois11]) AS [Novembre],Sum([mois12]) AS [Décembre]"
strSQL = strSQL & vbCrLf & "FROM R_Graphique_facturation_entre_date"
strSQL = strSQL & vbCrLf & "GROUP BY [Client_1]"
'Initialisation de la condition WHERE avec la catégorie
strSQL = strSQL & vbCrLf & "HAVING ((([Client_1])=" & Chr(34) & _
strCategory & Chr(34) & "));"
'Affectation du controle Frame
Me!fraCategories = 2
'Affectation de la nouvelle source et mise à jour de graphique
Graphique3.RowSource = strSQL
Graphique3.Requery
End Sub
Private Sub fraCategories_AfterUpdate()
Dim strSQL As String
Select Case Me!fraCategories
Case 1 'Toutes
'Désactivation du ComboBox et vidage
cmbClients.Enabled = False
Select Case fraQuartet
Case 1 'Janvier
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[[mois1]) AS [Janvier]"
Case 2 'Février
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois2]) AS [Février]"
Case 3 'Mars
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois3]) AS [Mars]"
Case 4 'Avril
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois4]) AS [Avril]"
Case 5 'Mai
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois5]) AS [Mai]"
Case 6 'Juin
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois6]) AS [Juin]"
Case 7 'Juillet
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois7]) AS [Juillet]"
Case 8 'Aout
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois8]) AS [Août]"
Case 9 'Septembre
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois9]) AS [Spetembre]"
Case 10 'Octobre
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois10]) AS [Octobre]"
Case 11 'Novembre
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois11]) AS [Novembre]"
Case 12 'Décembrere
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois12]) AS [Décembre]"
Case 13 'Tous
strSQL = "SELECT [Client_1],Sum([mois1]) AS [janvier]," & _
"Sum([mois2]) AS [février],Sum([mois3]) AS [Mars],Sum([mois4]) AS [avril],Sum([mois5]) AS [mai],Sum([mois6]) AS [Juin],Sum([mois7]) AS [Juillet],Sum([mois8]) AS [Août],Sum([mois9]) AS [Septembre],Sum([mois10]) AS [ctobre],Sum([mois11]) AS [Novembre],Sum([mois12]) AS [Décembre]"""
End Select
strSQL = strSQL & vbCrLf & "FROM R_Graphique_facturation_entre_date"
strSQL = strSQL & vbCrLf & "GROUP BY R_Graphique_facturation_entre_date.[Client_1];"
Graphique3.RowSource = strSQL
Graphique3.Requery
Case 2 'Une seule
'Activation du ComboBox avec Focus et déroulement
cmbClients.Enabled = True
cmbClients.SetFocus
cmbClients.Dropdown
End Select
End Sub
Private Sub fraQuartet_AfterUpdate()
Dim strSQL As String
Dim strCategory As String
Select Case Me!fraCategories
Case 1 'Janvier
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[[mois1]) AS [Janvier]"
Case 2 'Février
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois2]) AS [Février]"
Case 3 'Mars
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois3]) AS [Mars]"
Case 4 'Avril
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois4]) AS [Avril]"
Case 5 'Mai
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois5]) AS [Mai]"
Case 6 'Juin
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois6]) AS [Juin]"
Case 7 'Juillet
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois7]) AS [Juillet]"
Case 8 'Aout
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois8]) AS [Août]"
Case 9 'Septembre
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois9]) AS [Spetembre]"
Case 10 'Octobre
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois10]) AS [Octobre]"
Case 11 'Novembre
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois11]) AS [Novembre]"
Case 12 'Décembrere
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois12]) AS [Décembre]"
Case 13 'Tous
strSQL = "SELECT [Client_1],Sum([mois1]) AS [janvier]," & _
"Sum([mois2]) AS [février],Sum([mois3]) AS [Mars],Sum([mois4]) AS [avril],Sum([mois5]) AS [mai],Sum([mois6]) AS [Juin],Sum([mois7]) AS [Juillet],Sum([mois8]) AS [Août],Sum([mois9]) AS [Septembre],Sum([mois10]) AS [ctobre],Sum([mois11]) AS [Novembre],Sum([mois12]) AS [Décembre]"""
End Select
strSQL = strSQL & vbCrLf & "FROM R_Graphique_facturation_entre_date"
strSQL = strSQL & vbCrLf & "GROUP BY R_Graphique_facturation_entre_date.[Client_1];"
Graphique3.RowSource = strSQL
Graphique3.Requery
Case 2 'Une seule
cmbClients.SetFocus
If Len(Me!cmbClients.Text) Then
strCategory = Me!cmbClients.Text
Select Case fraQuartet
Case 1 'Janvier
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[[mois1]) AS [Janvier]"
Case 2 'Février
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois2]) AS [Février]"
Case 3 'Mars
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois3]) AS [Mars]"
Case 4 'Avril
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois4]) AS [Avril]"
Case 5 'Mai
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois5]) AS [Mai]"
Case 6 'Juin
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois6]) AS [Juin]"
Case 7 'Juillet
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois7]) AS [Juillet]"
Case 8 'Aout
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois8]) AS [Août]"
Case 9 'Septembre
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois9]) AS [Spetembre]"
Case 10 'Octobre
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois10]) AS [Octobre]"
Case 11 'Novembre
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois11]) AS [Novembre]"
Case 12 'Décembrere
strSQL = "SELECT R_Graphique_facturation_entre_date.[Client_1], " & _
"Sum(R_Graphique_facturation_entre_date.[mois12]) AS [Décembre]"
Case 13 'Tous
strSQL = "SELECT [Client_1],Sum([mois1]) AS [janvier]," & _
"Sum([mois2]) AS [février],Sum([mois3]) AS [Mars],Sum([mois4]) AS [avril],Sum([mois5]) AS [mai],Sum([mois6]) AS [Juin],Sum([mois7]) AS [Juillet],Sum([mois8]) AS [Août],Sum([mois9]) AS [Septembre],Sum([mois10]) AS [ctobre],Sum([mois11]) AS [Novembre],Sum([mois12]) AS [Décembre]"""
End Select
strSQL = strSQL & vbCrLf & "FROM R_Graphique_facturation_entre_date"
strSQL = strSQL & vbCrLf & "GROUP BY R_Graphique_facturation_entre_date.[Client_1]"
'Initialisation de la condition WHERE avec la catégorie
strSQL = strSQL & vbCrLf & "HAVING ((([Client_1])=" & Chr(34) & _
strCategory & Chr(34) & "));"
Graphique3.RowSource = strSQL
Graphique3.Requery
Else
MsgBox "Une catégorie doit être sélectionnée !", 48, "Catégorie requise"
cmbClients.SetFocus
cmbClients.Dropdown
End If
End Select
End Sub |
Partager