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
| Private Sub cmdValider_click()
Dim id_MaintenancePréventive, ID_Personnel, DuréeIntervention As Integer
Dim sql, Commentaire As String
Dim DateMaintenancePréventive As Date, DatePrevueInitialement As Date
Dim oRst As DAO.Recordset
Dim odb As DAO.Database
If Me.txtIDDemande.Caption = "null" Then Exit Sub
Set odb = CurrentDb
id_MaintenancePréventive = Me.txtIDDemande.Caption
Commentaire = Me.txtCommentaire
Commentaire = Replace(Commentaire, "'", "''")
DuréeIntervention = Me.listeDurée
sql = "select * from tbl_MaintenancePréventive where id_MaintenancePréventive = " & id_MaintenancePréventive & ";"
Set oRst = odb.OpenRecordset(sql, dbOpenDynaset)
ID_Périodicité = oRst.Fields("ID_Périodicité").Value
DatePrevueInitialement = oRst.Fields("DateProchaineIntervention").Value
sql = "Select NombreDeJours from tbl_Périodicité where ID_Periodicité = " & ID_Périodicité & ""
Set oRst = odb.OpenRecordset(sql, dbOpenDynaset)
ProchaineIntervention = oRst.Fields("NombreDeJours").Value + Date
sql = "Update tbl_MaintenancePréventive set DateDerniéreIntervention='" & Date & "', DateProchaineIntervention = '" & ProchaineIntervention & "' where ID_MaintenancePréventive =" & id_MaintenancePréventive & ";"
odb.Execute (sql)
sql = "Select Max(ID_HistoriqueMaintenancePréventive) from tbl_HistoriqueMaintenancePréventive"
Set oRst = odb.OpenRecordset(sql, dbOpenDynaset)
id_HistoriqueMaintenancePréventive = oRst.Fields(0).Value + 1
ID_Personnel = Me.listeIntervenant
sql = "insert into tbl_HistoriqueMaintenancePréventive values (" & id_HistoriqueMaintenancePréventive & ", '" & id_MaintenancePréventive & "' ," & ID_Personnel & ",'" & Date & "', '" & DatePrevueInitialement & "', '" & Commentaire & "', " & DuréeIntervention & " )"
odb.Execute (sql)
MsgBox ("Votre Intervention a été correctement enregistrée")
DoCmd.Close
Form_SignalerMaintenancePreventiveTerminé.Refresh
Form_SignalerMaintenancePreventiveTerminé.txtRetard.Caption = ""
End Sub |
Partager