[VBA][recordset]pb update error 3061 too few parameters
salut ,
en fait je voudrais modifié un nom que je selectionne dans une combo
ensuite je fais ma requete sql avec mon recordset je fais un edit + update
et j ai erreur suivant sur la requete sql error 3061 too few parameters expected 1
je ne comprends pas ou est mon erreur pourtant j ai regardé le tuto recordset
Code:
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
|
Private Sub btncontrat_Click()
Dim db As DAO.Database
Dim rsmodifcontrat As Recordset
Dim oldcontrat As Integer
Dim newcontrat As Integer
oldcontrat = combocontrat.Value
newcontrat = TxtBoxcontrat.Value
Set db = DBEngine.OpenDatabase("d:\invoice.mdb", True)
Set rsmodifcontrat = db.OpenRecordset("select * from contrat where contrat_nb = oldcontrat", dbOpenDynaset)
With rsmodifcontrat
While Not .EOF
.Edit
.Fields("contrat_nb").Value = newcontrat 'edition du champs et attribue la valeur de la textbox
.Update
.MoveNext
Wend
End With
rsmodifcontrat.Close
db.Close
Set rsmodifcontrat = Nothing
Set db = Nothing
End Sub |
voila merci :oops: :wink: