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 48 49
| Private Sub btnAjouterEleve_Click()
Dim db As Database
Dim rs As Recordset
Dim idEleve As Integer
Dim urlPhoto As String
urlPhoto = CurrentProject.Path & "\Gpe_Scol_Paoufla\PhotoBase\"
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM T_Eleves", dbOpenDynaset)
rs.AddNew
idEleve = rs("idEleve")
rs("Matricule") = Me.txtMatricule
rs("Nom") = Me.txtNom
rs("Prenom") = Me.txtPrenom
rs("Sexe") = Me.txtSexe
rs("DateNaissance") = Me.txtDateNaiss
rs("LieuNaissance") = Me.txtLieudeNaiss
rs("ActedeNaissance") = Me.txtExtrait
rs("Pere") = Me.txtPere
rs("Mere") = Me.txtMere
rs("Adresse") = Me.txtAdresse
rs("Telephone") = Me.txtTel
rs("Photo") = urlPhoto & idEleve & getExtFile(Me.txtAdressePhotoSource)
rs.Update
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub
======================================
Public Function getExtFile(Path As String) As String
Dim posPoint As Integer
posPoint = InStrRev(Path, ".")
Dim ext As String
ext = Right(Path, Len(Path) - posPoint)
getExtFile = ext
End Function
======================================
Private Sub btnChargerPhoto_Click()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.Title = "Selectionner la Photo"
.InitialFileName = CurrentProject.Path
If .Show <> 0 Then
txtPhoto.Picture = .SelectedItems(1)
Me.txtAdressePhotoSource = .SelectedItems(1)
End If
End With
End Sub |
Partager