Need some help with the issue described below. Would be great to get some genius to have a look onto this.
Case
Employee Database
Report that shows Employees with a linked picture
Problem
The Problem is that with the code I used below the picture for all employees are the same. As soon as I click on the report to a diffrent employee entry all pictures change to that employee.
So instead of getting for every employee a diffrent picture I get the same picture for all employees depending on which entry I just clicked.
Code
Code:
Private Sub Report_Current()
'Linkes the Image in the Report to a specific Picture depending on the primary key (Personalnummer)
Dim ximg, path, sFile
path = "C:\Fotos\"
ximg = Me![Personalnummer]
sFile = path & ximg & ".jpg"
If File_Exists(sFile) = True Then
Me.Photo.Picture = path & ximg & ".jpg"
Else
Me.Photo.Picture = path & "placeholder.jpg"
End If
End Sub
Private Function File_Exists(ByVal sPathName As String, Optional Directory As Boolean) As Boolean
'Returns True if the passed sPathName exist
'Otherwise returns False
On Error Resume Next
If sPathName <> "" Then
If IsMissing(Directory) Or Directory = False Then
File_Exists = (Dir$(sPathName) <> "")
Else
File_Exists = (Dir$(sPathName, vbDirectory) <> "")
End If
End If
End Function