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
| Private Sub lstResults_DblClick(Cancel As Integer)
Dim Descriptif As String, sql As String
Dim DateIntervention As Date
Dim compteur As Integer, id_Intervention As Integer, ID_Machine As Integer, Id_Ligne As Integer, ID_Type As Integer, ID_Categorie As Integer, ID_Diagnostic As Integer, ID_DuréeArret As Integer, ID_DuréeIntervention As Integer, ID_tech1 As Integer, ID_tech2 As Integer, ID_Référence As Integer, quantité As Integer
Dim oRst As DAO.Recordset
Dim odb As DAO.Database
Set odb = CurrentDb
If IsNull(Me.lstResults.Column(0)) Then
MsgBox ("Il n'y a actuellement aucun travaux dans la liste")
Exit Sub
Else
id_Intervention = Me.lstResults.Column(0)
End If
sql = "select * from tbl_Intervention where ID_intervention = " & id_Intervention & ";"
Set oRst = odb.OpenRecordset(sql, dbOpenDynaset)
DateIntervention = oRst.Fields("DateIntervention").Value
ID_Machine = Nz(oRst.Fields("ID_Machine").Value, 0)
ID_Type = Nz(oRst.Fields("ID_Type").Value, 0)
ID_Catégorie = Nz(oRst.Fields("ID_Catégorie").Value, 0)
Descriptif = Nz(oRst.Fields("Descriptif").Value, "")
ID_Diagnostic = Nz(oRst.Fields("ID_Diagnostic").Value, 0)
ID_DuréeArret = Nz(oRst.Fields("DuréeArrétMachine").Value, 0)
ID_DuréeIntervention = Nz(oRst.Fields("DureéIntervention").Value, 0)
DoCmd.OpenForm ("DetailIntervention")
Form_DetailIntervention.txtDateIntervention.Value = DateIntervention
Form_DetailIntervention.listeMachine.Value = ID_Machine
Form_DetailIntervention.listeTypeIntervention = ID_Type
Form_DetailIntervention.listeNatureintervention.Value = ID_Catégorie
Form_DetailIntervention.txtDescriptifIntervention.Value = Descriptif
Form_DetailIntervention.listeDiagnostic.Value = ID_Diagnostic
Form_DetailIntervention.listeDuréeArretProduction.Value = ID_DuréeArret
Form_DetailIntervention.listeDuréeIntervention.Value = ID_DuréeIntervention
Form_DetailIntervention.listeLigneDeProduction.Value = Form_DetailIntervention.listeMachine.Column(1)
sql = "SELECT tbl_PiécesChangées.ID_référence, tbl_Désignation.Désignation, tbl_Référence.Référence, tbl_PiécesChangées.Quantité as Qté FROM (tbl_Désignation INNER JOIN tbl_Référence ON tbl_Désignation.[ID_Désignation] = tbl_Référence.[ID_Désignation]) INNER JOIN tbl_PiécesChangées ON tbl_Référence.[ID_Référence] = tbl_PiécesChangées.[ID_référence] WHERE (((tbl_PiécesChangées.ID_intervention)=" & id_Intervention & "));"
Form_DetailIntervention.listePiécesChangées.RowSource = sql
sql = "SELECT Count(*) FROM (SELECT tbl_Intervenir.ID_Intervention FROM tbl_Intervenir WHERE (((tbl_Intervenir.ID_Intervention)=" & id_Intervention & ")));"
Set oRst = odb.OpenRecordset(sql, dbOpenDynaset)
compteur = Nz(oRst.Fields(0).Value, 0)
sql = "SELECT tbl_Intervenir.ID_Personnel FROM tbl_Intervenir WHERE tbl_Intervenir.ID_Intervention=" & id_Intervention & ";"
Set oRst = odb.OpenRecordset(sql, dbOpenDynaset)
If compteur = 1 Then
oRst.MoveFirst
ID_tech1 = Nz(oRst.Fields(0).Value, 0)
End If
If compteur = 2 Then
oRst.MoveFirst
ID_tech1 = Nz(oRst.Fields(0).Value, 0)
oRst.MoveLast
ID_tech2 = Nz(oRst.Fields(0).Value, 0)
End If
Form_DetailIntervention.listeIntervenant1.Value = ID_tech1
Form_DetailIntervention.listeIntervenant2.Value = ID_tech2
End Sub |
Partager