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
|
Private Sub valider_Click()
Dim la_base As Database: Dim ligne As Recordset
Dim requete As String
Dim cherche As String: Dim position As Integer
If (Matricule.Value = "" Or IsNull(Matricule.Value) Or Nom.Value = "" Or IsNull(Nom.Value) Or Prenoms.Value = "" Or IsNull(Prenoms.Value) Or Date_Naiss.Value = "" Or IsNull(Date_Naiss.Value)) Then
MsgBox "Tous les renseignements sont obligatoires"
Else
requete = "SELECT Elève.Matricule,Elève.Nom,Elève.Prenoms FROM Elève WHERE Elève.Matricule='" & Matricule.Value & "'"
Set la_base = Application.CurrentDb
Set ligne = la_base.OpenRecordset(requete, dbOpenDynaset)
If (ligne.RecordCount > 0) Then
MsgBox "Cet identifiant existe déjà !, veuillez en changer"
'Matricule.Value = ""
ligne.Close
la_base.Close
Exit Sub
Else
requete = "INSERT INTO Elève(Matricule,Nom,Prenoms,Date_Naiss,Id_niv,Id_AnneeScolaire )VALUES ('" & Matricule.Value & "','" & Nom.Value & "','" & Prenoms.Value & "','" & Date_Naiss.Value & "','" & Id_niv.Value & "','" & Id_AnneeScolaire.Value & "' )"
la_base.Execute requete
MsgBox "Vous êtes désormais inscrit(e)"
DoCmd.OpenForm "Login_Eleve", acDesign
Form_Login_Eleve.recup.Caption = Matricule.Value 'Car pas possible pour une zone de texte en value, donc intermédiaire
Form_Login_Eleve.nom_du_candidat = Nom.Value & " " & Prenoms.Value
DoCmd.Close acForm, "Login_Eleve", acSaveYes
DoCmd.OpenForm "Login_Eleve", acNormal
DoCmd.Close acForm, "inscription", acSaveNo
ligne.Close
la_base.Close
Set la_base = Nothing
Set ligne = Nothing
End If
End Sub |
Partager