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
| Private Sub Compte_Produit()
Dim TxtSQL, TxtSQL0 As String
Dim TxtSQL1, TxtSQL2, TxtSQL3, TxtSQL4, TxtSQL5 As String
Dim DateDebut, DateFin As Date
Dim Donnees, Donnees0 As Recordset
Dim Donnees1, Donnees2, Donnees3, Donnees4, Donnees5 As Recordset
'initialisation
DateDebut = Me!DateDebut
DateFin = Me!DateFin
'Nombre de produit
TxtSQL = "SELECT COUNT(Test_SerialNr) AS compte FROM (SELECT Test_SerialNr FROM [TABLE RESULTATS] WHERE Date >= #" & Format(DateDebut, "dd/mm/yyyy 00:00:00") & "# And Date <= #" & Format(DateFin, "dd/mm/yyyy 23:59:59") & "# GROUP BY Test_SerialNr)"
Set Donnees = CurrentDb.OpenRecordset(TxtSQL, dbOpenDynaset)
Donnees.MoveFirst
Me!NombreProduitTotal = Donnees!Compte
Donnees.Close
Set Donnees = Nothing
'Moins de un passage
TxtSQL0 = "SELECT COUNT(Test_SerialNr) AS compte FROM (SELECT Test_SerialNr FROM [TABLE RESULTATS] WHERE Date >= #" & Format(DateDebut, "dd/mm/yyyy 00:00:00") & "# And Date <= #" & Format(DateFin, "dd/mm/yyyy 23:59:59") & "# GROUP BY Test_SerialNr HAVING Count(Date)<15)"
Set Donnees0 = CurrentDb.OpenRecordset(TxtSQL0, dbOpenDynaset)
Donnees0.MoveFirst
Me!ProduitControleNonFinis = Donnees0!Compte
'Un passage
TxtSQL1 = "SELECT COUNT(Test_SerialNr) AS compte FROM (SELECT Test_SerialNr FROM [TABLE RESULTATS] WHERE Date >= #" & Format(DateDebut, "dd/mm/yyyy 00:00:00") & "# And Date <= #" & Format(DateFin, "dd/mm/yyyy 23:59:59") & "# GROUP BY Test_SerialNr HAVING Max(Test_Order)=1)"
Set Donnees1 = CurrentDb.OpenRecordset(TxtSQL1, dbOpenDynaset)
Donnees1.MoveFirst
Me!ProduitsConformes = Donnees1!Compte - Donnees0!Compte
Donnees0.Close
Set Donnees0 = Nothing
Donnees1.Close
Set Donnees1 = Nothing
'Deux Passages
TxtSQL2 = "SELECT Count(Test_SerialNr) AS compte FROM (SELECT Test_SerialNr FROM [TABLE RESULTATS] WHERE Date >= #" & Format(DateDebut, "dd/mm/yyyy 00:00:00") & "# And Date <= #" & Format(DateFin, "dd/mm/yyyy 23:59:59") & "# GROUP BY Test_SerialNr HAVING Max(Test_Order)=2)"
Set Donnees2 = CurrentDb.OpenRecordset(TxtSQL2, dbOpenDynaset)
Donnees2.MoveFirst
Me!ProduitDeuxCoup = Donnees2!Compte
Donnees2.Close
Set Donnees2 = Nothing
'Trois Passages
TxtSQL3 = "SELECT COUNT(Test_SerialNr) AS compte FROM (SELECT Test_SerialNr FROM [TABLE RESULTATS] WHERE Date >= #" & Format(DateDebut, "dd/mm/yyyy 00:00:00") & "# And Date <= #" & Format(DateFin, "dd/mm/yyyy 23:59:59") & "# GROUP BY Test_SerialNr HAVING Max(Test_Order)=3)"
Set Donnees3 = CurrentDb.OpenRecordset(TxtSQL3, dbOpenDynaset)
Donnees3.MoveFirst
Me!ProduitTroisCoup = Donnees3!Compte
Donnees3.Close
Set Donnees3 = Nothing
'Quatre Passages
TxtSQL4 = "SELECT COUNT(Test_SerialNr) AS compte FROM (SELECT Test_SerialNr FROM [TABLE RESULTATS] WHERE Date >= #" & Format(DateDebut, "dd/mm/yyyy 00:00:00") & "# And Date <= #" & Format(DateFin, "dd/mm/yyyy 23:59:59") & "# GROUP BY Test_SerialNr HAVING Max(Test_Order)=4)"
Set Donnees4 = CurrentDb.OpenRecordset(TxtSQL4, dbOpenDynaset)
Donnees4.MoveFirst
Me!ProduitQuatreCoup = Donnees4!Compte
Donnees4.Close
Set Donnees4 = Nothing
'Plus de Quatre Passages
TxtSQL5 = "SELECT COUNT(Test_SerialNr) AS compte FROM (SELECT Test_SerialNr FROM [TABLE RESULTATS] WHERE Date >= #" & Format(DateDebut, "dd/mm/yyyy 00:00:00") & "# And Date <= #" & Format(DateFin, "dd/mm/yyyy 23:59:59") & "# GROUP BY Test_SerialNr HAVING Max(Test_Order)>4)"
Set Donnees5 = CurrentDb.OpenRecordset(TxtSQL5, dbOpenDynaset)
Donnees5.MoveFirst
Me!ProduitPlusQuatreCoup = Donnees5!Compte
Donnees5.Close
Set Donnees5 = Nothing |
Partager