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
| Private Sub BtnValider_Click()
Dim Db As Database
Dim RS, rsEnreg As DAO.Recordset
Dim nenreg, compteur As String
Dim num As Integer
Dim Nom, Reponse As String
Dim requete As String
Set Db = OpenDatabase("projet.mdb")
Set rsEnreg = Db.OpenRecordset("PROJET", dbOpenTable)
If (rsEnreg.RecordCount > 0) Then
rsEnreg.MoveFirst
Do Until rsEnreg.EOF
nenreg = rsEnreg("NumProjet").Value
rsEnreg.MoveNext
Loop
num = CInt(Right(nenreg, 2)) + 1
If (num < 10) Then
compteur = Left(nenreg, 1) + "0" + CStr(num)
Else
compteur = Left(nenreg, 1) + CStr(num)
End If
Else
compteur = "P01"
End If
requete = "INSERT INTO PROJET (NumProjet,CodeCategorie,Nom,Lien,Prix,Technologie,Image,Sold,Description) VALUES ('" & compteur & "',1,'" & TxtNom.Text & "','" & TxtLien.Text & "'," & TxtPrix.Text & ",'techno','image','oui','description')"
Debug.Print requete
Db.Execute (requete)
rsEnreg.Close
Set rsEnreg = Nothing
Set Db = Nothing
Reponse = MsgBox("Votre projet a été ajouté", vbOKOnly, "Succès")
End Sub |
Partager