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
|
Dim CNX As ADODB.Connection
Set CNX = CurrentProject.Connection
Dim RS As ADODB.Recordset
Set RS = New ADODB.Recordset
Dim Boucle As Integer, BoucleMax As Integer, I As Integer, NbreChamps As Integer
Dim MinDate As Date, MaxDate As Date, MinIndex As Integer, MaxIndex As Integer
'Restauration de la table source du graphique
SupprimerTable "base_graphique"
CopierTable "base_graphique_temp", "base_graphique"
'Modification de la table source par des requêtes SQL puis mise à jour du titre
Me.Graphique.Object.Application.Chart.ChartTitle.Caption = Me.designation.Value
'Calcul des bornes du graphique
MinIndex = 0
MaxIndex = 0
With RS
.Open "base_graphique", CNX, adOpenForwardOnly, adLockPessimistic
.MoveFirst
MinDate = .Fields(6).name
MaxDate = .Fields(.Fields.Count - 1).name
Do Until .EOF
For Boucle = 6 To (.Fields.Count - 1)
If .Fields(Boucle) > MaxIndex Then
MaxIndex = .Fields(Boucle)
End If
If .Fields(Boucle) < MinIndex Then
MinIndex = .Fields(Boucle)
End If
Next Boucle
.MoveNext
Loop
.Close
End With
'Application des nouvelles bornes du graphique
Me.Graphique.Object.Application.Chart.Axes(2).MinimumScale = MinIndex
Me.Graphique.Object.Application.Chart.Axes(2).MaximumScale = MaxIndex
Me.Graphique.Object.Application.Chart.Axes(2).MaximumScaleIsAuto = True
Me.Graphique.Object.Application.Chart.Axes(1).MinimumScale = MinDate
Me.Graphique.Object.Application.Chart.Axes(1).MaximumScale = MaxDate
Me.Graphique.Object.Application.Chart.Axes(1).MaximumScaleIsAuto = True
Me.Graphique.Requery |
Partager