merci à l'équipe
Svp aidez moi, je suis bloqué
j'ai une erreur 3021 lors de la modification d'un enregistrement.
Private Sub CmdEdit_Click()
Dim db As Database
Dim rs As Recordset
If txtIdentPat(0).Text = "" Then MsgBox ("Please fill in the Numéro first!"), vbOKOnly + vbCritical, "Error" _
: Exit Sub
If txtIdentPat(1).Text = "" Then MsgBox ("Please fill in the Nom first!"), vbOKOnly + vbCritical, "Error" _
: Exit Sub
If txtIdentPat(2).Text = "" Then MsgBox ("Please fill in the Prénom number first!"), vbOKOnly + vbCritical, "Error" _
: Exit Sub
If txtIdentPat(3).Text = "" Then MsgBox ("Please fill in the Sex number first!"), vbOKOnly + vbCritical, "Error" _
: Exit Sub
Set db = OpenDatabase(App.Path + "\Rhazi.mdb")
Set rs = db.OpenRecordset("Select * from A_Pat where Nom = '" & Trim(lvRecNames.SelectedItem.Text) & "'")
With rs
' While Not .EOF 'ça marche pas
.Edit
rs![Num] = IIf(IsNull(txtIdentPat(0).Text), "", (txtIdentPat(0).Text))
rs![Nom] = IIf(IsNull(txtIdentPat(1).Text), "", (txtIdentPat(1).Text))
rs![Prenom] = IIf(IsNull(txtIdentPat(2).Text), "", (txtIdentPat(2).Text))
rs![Sexe] = IIf(IsNull(txtIdentPat(3).Text), "", (txtIdentPat(3).Text))
.Update
' Wend
End With
MsgBox ("The new record is modified to the database!"), vbOKOnly + vbInformation, "Modified"
rs.Close
db.Close
Call cmdRead_Click
lvRecNames.Enabled = True
lvRecNames.SetFocus
End Sub
