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
| Private Sub cmdeValider_click()
Dim message As String, Element As String, Descriptif As String, Consigne As String, Outillage As String, Numero As String
Dim ID_MaintenancePréventive As Integer, Ligne As Integer, Machine As Integer, Periodicite As Integer, TypeIntervention As Integer
Dim DateDerniere As Date, DateProchaine As Date
Dim oRst As DAO.Recordset
Dim odb As DAO.Database
'Test si des champs sont null : si oui message d'erreur et arrrét
If IsNull(Me.listeLigne) Or IsNull(Me.listeMachine) Or IsNull(Me.listePeriodicité) Or IsNull(Me.txtDescriptif) Or IsNull(Me.txtElement) Or IsNull(Me.txtDateDernièreIntervention) Then
MsgBox ("Merci de Remplir les champs Obligatoires")
Exit Sub
End If
If Me.txtIDMP.Caption = "null" Then Exit Sub
'Affectation des valeur correspondantes aux variables
ID_MaintenancePréventive = Me.txtIDMP.Caption
Ligne = Me.listeLigne
Machine = Me.listeMachine
Periodicite = Me.listePeriodicité
TypeIntervention = Me.listeType
Element = Me.txtElement
Descriptif = Me.txtDescriptif
Consigne = Me.txtConsigneSecurité
Outillage = Me.txtOutillageSpécial
Numero = Me.txtNumeroDeGamme
DateDerniere = Me.txtDateDernièreIntervention
DateProchaine = Me.txtDateProchaineIntervention
'on remplace les apostrophe pas des doubles apostrophes sinon la réquéte ne fonctionne pas
Element = Replace(Element, "'", "''")
Descriptif = Replace(Descriptif, "'", "''")
Consigne = Replace(Consigne, "'", "''")
Outillage = Replace(Outillage, "'", "''")
Numero = Replace(Numero, "'", "''")
DateDerniere = Replace(DateDerniere, "'", "''")
DateProchaine = Replace(DateProchaine, "'", "''")
Set odb = CurrentDb
sql = "select * from tbl_MaintenancePréventive where ID_MaintenancePréventive = " & ID_MaintenancePréventive & ";"
Set oRst = odb.OpenRecordset(sql, dbOpenDynaset)
Set odb = CurrentDb
sql = "Update tbl_MaintenancePréventive set ID_Machine=" & Machine & ", ID_Périodicité=" & Periodicite & ", ID_Type=" & TypeIntervention & ", Element='" & Element & "', Descriptif='" & Descriptif & "' , ConsigneSécurité='" & Consigne & "', OutillageSpécial='" & Outillage & "', Gamme='" & Numero & "', DateDerniéreIntervention=" & DateDerniere & ", DateProchaineIntervention=" & DateProchaine & ";"
odb.Execute (sql)
message = MsgBox("Les modifications ont été prises en compte", vbInformation, "Modification Réussie")
DoCmd.Close
End Sub |
Partager