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
| Ms = [Forms]![frm-Maitre-Operation]![sfm_Onglet].[Form]![lmd-mois]
sSQL1 = "SELECT Format([Date],""mmmm"") AS Mois,[rqt-G-Eff-5-Groupe].Groupe AS Groupe, Sum([rqt-G-Eff-5-Groupe].Fct) AS Fct, Sum([rqt-G-Eff-5-Groupe].[Temps AP]) AS [Temps AP], Sum([rqt-G-Eff-5-Groupe].[Temps ANP]) AS [Temps ANP], Sum([rqt-G-Eff-5-Groupe].[Temps Dysfonct]) AS [Temps Dysfonct], Sum([rqt-G-Eff-5-Groupe].[Temps desengage]) AS [Temps desengage], Sum([rqt-G-Eff-5-Groupe].Qual) AS Qual"
sSQL1 = sSQL1 & " FROM [rqt-G-Eff-5-Groupe]"
sSQL1 = sSQL1 & " GROUP BY Format([Date],""mmmm""),Groupe"
sSQL1 = sSQL1 & " HAVING (((Format([Date],""mmmm""))='" & Ms & "'))and Groupe='" & Groupe & "';"
DoCmd.DeleteObject acQuery, "rqt-G-repart-tps-Groupe-MTD"
CurrentDb.CreateQueryDef "rqt-G-repart-tps-Groupe-MTD", sSQL1
MTDt = DLookup("Mois", "rqt-G-repart-tps-Groupe-MTD")
g = DLookup("Groupe", "rqt-G-repart-tps-Groupe-MTD")
Fct = Round(((Nz(DLookup("Fct", "rqt-G-repart-tps-Groupe-MTD"), 0)) / 60), 2)
AP = Round(((Nz(DLookup("[Temps AP]", "rqt-G-repart-tps-Groupe-MTD"), 0)) / 60), 2)
ANP = Round(((Nz(DLookup("[Temps ANP]", "rqt-G-repart-tps-Groupe-MTD"), 0)) / 60), 2)
Dysfonct = Round(((Nz(DLookup("[Temps Dysfonct]", "rqt-G-repart-tps-Groupe-MTD"), 0)) / 60), 2)
desengage = Round(((Nz(DLookup("[Temps desengage]", "rqt-G-repart-tps-Groupe-MTD"), 0)) / 60), 2)
Qual = Round(((Nz(DLookup("Qual", "rqt-G-repart-tps-Groupe-MTD"), 0)) / 60), 2)
sSQL = "CREATE TABLE [Graph repart tps MTD Groupe]( [Mois] text(50));"
DoCmd.RunSQL (sSQL)
Set a = CurrentDb.QueryDefs("rqt-G-repart-tps-Groupe-MTD")
For Each f In a.Fields
n = f.Name
If n <> "Mois" And n <> "Groupe" Then
sSQL1 = "ALTER TABLE [Graph repart tps MTD Groupe] ADD [" & n & "] single"
DoCmd.RunSQL (sSQL1)
End If
Next
DoCmd.SetWarnings (False)
'évite l'affichage du message de confirmation d'ajout, supp d'une requete
sSQL2 = "INSERT INTO [Graph repart tps MTD Groupe] ([Mois],[Fct], [Temps AP], [Temps ANP],[Temps Dysfonct],[Temps desengage],[Qual] ) VALUES ('" & MTDt & "','" & Fct & "', '" & AP & "','" & ANP & "','" & Dysfonct & "','" & desengage & "','" & Qual & "')"
DoCmd.RunSQL (sSQL2)
DoCmd.SetWarnings (True)
db.TableDefs.Refresh
Set tbl9 = db.TableDefs("Graph repart tps MTD Groupe")
tbl9.Fields("Fct").Name = "Temps Fct"
tbl9.Fields("Qual").Name = "Perte Qualité"
tbl9.Fields("Temps AP").Name = "Perte AP"
tbl9.Fields("Temps ANP").Name = "Perte ANP"
tbl9.Fields("Temps Dysfonct").Name = "Perte Dysfct"
tbl9.Fields("Temps desengage").Name = "Perte desg"
Dim t(6) As Long
t(0) = Fct
t(1) = AP
t(2) = ANP
t(3) = Dysfonct
t(4) = desengage
t(5) = Qual
q0 = 2
q1 = 2
q2 = 2
q3 = 2
q4 = 2
q5 = 2
For i = 1 To 5
If t(0) < t(i) Then
q0 = q0 + 1
End If
Next
For i = 0 To 5
If i = 1 Then
i = 2
End If
If t(1) < t(i) Then
q1 = q1 + 1
End If
Next
For i = 0 To 5
If i = 2 Then
i = 3
End If
If t(2) < t(i) Then
q2 = q2 + 1
End If
Next
For i = 0 To 5
If i = 3 Then
i = 4
End If
If t(3) < t(i) Then
q3 = q3 + 1
End If
Next
For i = 0 To 5
If i = 4 Then
i = 5
End If
If t(4) < t(i) Then
q4 = q4 + 1
End If
Next
For i = 0 To 4
If t(5) < t(i) Then
q5 = q5 + 1
End If
Next
Set fld = tbl9.Fields("Temps Fct")
fld.OrdinalPosition = q0
Set fld = tbl9.Fields("Perte AP")
fld.OrdinalPosition = q1
Set fld = tbl9.Fields("Perte ANP")
fld.OrdinalPosition = q2
Set fld = tbl9.Fields("Perte Dysfct")
fld.OrdinalPosition = q3
Set fld = tbl9.Fields("Perte desg")
fld.OrdinalPosition = q4
Set fld = tbl9.Fields("Perte Qualité")
fld.OrdinalPosition = q5 |
Partager