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
| Private Sub CmdValider_click()
Dim Reclamation As String
Dim Identité As Integer, Ligne As Integer, Machine As Integer, ID_Réclamation As Integer
Dim DateReclamation As Date
Dim oRst As DAO.Recordset
Dim odb As DAO.Database
If IsNull(Me.ListeIdentité) Or IsNull(Me.cmbLigne) Or IsNull(Me.cmbMachine) Or IsNull(Me.txtRéclamation) Then
MsgBox ("Merci de remplir tous les champs")
Exit Sub
End If
Identité = Me.ListeIdentité
Ligne = Me.cmbLigne
Machine = cmbMachine
Reclamation = txtRéclamation
DateReclamation = Date
Reclamation = Replace(Reclamation, "'", "''")
Set odb = CurrentDb
sql = "SELECT ID_Réclamation FROM tbl_Réclamation where ID_Réclamation =(SELECT MAX(ID_Réclamation) FROM tbl_Réclamation)"
Set oRst = odb.OpenRecordset(sql, dbOpenDynaset)
ID_Réclamation = oRst.Fields("ID_Réclamation").Value + 1
sql = "INSERT into tbl_Réclamation values (" & ID_Réclamation & "," & DateReclamation & "," & Identité & "," & Ligne & "," & Machine & ",'" & Reclamation & "')"
odb.Execute (sql)
oRst.Close
odb.Close
Set oRst = Nothing
Set odb = Nothing
message = MsgBox("Votre réclamation : " & Reclamation & " a été correctement enregistrée", vbInformation, "Ajout")
DoCmd.Close
End Sub |
Partager