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
| Option Explicit
Dim DossRacine As String
Private Sub Form_Load()
DossRacine = App.Path
ChargeTblBDS
End Sub
Private Sub ChargeTblBDS()
Dim CnX As New ADODB.Connection 'pour la connexion à la BD
Dim Rs As New ADODB.Recordset '
' remplir le ListBox
Rs.Open "collaborateur", CnX, adOpenStatic, adLockPessimistic
Do While Not Rs.EOF
List1.AddItem Rs.Fields("Nom") & " " & Rs.Fields("Prenom")
List1.ItemData(List1.NewIndex) = Rs.Fields("Matricule")
Rs.MoveNext 'passage à l'enregistrement suivant
Loop
Rs.Close
End Sub
Private Sub List1_Click()
'pour actualiser l'image du collaborateur
Dim CheminImage As String
CheminImage = DossRacine & "\Dossier Photos\" & Replace(List1.List(List1.ListIndex), " ", "") & List1.ItemData & ".jpg"
Image1.Picture = LoadPicture(CheminImage)
End Sub |
Partager