lhtqasonline
06-22-2009, 02:39 AM
Hi
I need to show a picture of person in a userform.
The userform is a employee database.
I used Application.Match to view data from a spreadsheet in the userform.
What I now need to do is load the id foto of the person in the image box on my userform.
I tried the following code (snipped from code found in this website)
Me.EmplNo is the one i would like to use to match with the picture file
I named the picture (stored in the same directory) to match the EmplNo field.
Private Sub Show_Pic()
Dim EmpFound As Range
Dim fPath As String
Set EmpFound = Me.EmplNo
On Error Resume Next
If EmpFound Is Nothing Then
Image2.Picture = LoadPicture(fPath & "nopic.gif")
Else
With EmpFound
'Look in the directory where this workbook is located.
fPath = ThisWorkbook.Path & "\"
On Error Resume Next
'If a matching picture is found then display it.
Image2.Picture = LoadPicture(fPath & "\" & ListBox1.Value & ".jpg")
'If No picture found then display the default picture.
If Err = 0 Then Exit Sub
Image2.Picture = LoadPicture(fPath & "nopic.gif")
End If
End With
End Sub
Please help
I need to show a picture of person in a userform.
The userform is a employee database.
I used Application.Match to view data from a spreadsheet in the userform.
What I now need to do is load the id foto of the person in the image box on my userform.
I tried the following code (snipped from code found in this website)
Me.EmplNo is the one i would like to use to match with the picture file
I named the picture (stored in the same directory) to match the EmplNo field.
Private Sub Show_Pic()
Dim EmpFound As Range
Dim fPath As String
Set EmpFound = Me.EmplNo
On Error Resume Next
If EmpFound Is Nothing Then
Image2.Picture = LoadPicture(fPath & "nopic.gif")
Else
With EmpFound
'Look in the directory where this workbook is located.
fPath = ThisWorkbook.Path & "\"
On Error Resume Next
'If a matching picture is found then display it.
Image2.Picture = LoadPicture(fPath & "\" & ListBox1.Value & ".jpg")
'If No picture found then display the default picture.
If Err = 0 Then Exit Sub
Image2.Picture = LoadPicture(fPath & "nopic.gif")
End If
End With
End Sub
Please help