This is probably over the top for what you want, but it is relatively watertight
Add an Image Control to your report (probably in the detail section)
I assume you also have a field in your record called something like PhotoPath.
Then on the OnFormat of the Detail add
-
FindOldPhotoRpt(Rpt As Report, PhotoPath As String)
-
This is the code that you need
-
Public Function FindOldPhotoRpt(Rpt As Report, PhotoPath As String)
-
-
'HKEY_LOCAL_MACHINE\Software\Microsoft\ Shared Tools\Graphics Filters\Import\JPEG\Options ShowProgressDialog No
-
-
Dim MyDb As Database
-
Dim ImageTypeSet As Recordset
-
Dim Msg As String, FilterName As String
-
Dim FullPhotoPath As String
-
-
If Nz(PhotoPath) = "" Then
-
Rpt!Photo.Picture = ""
-
Exit Function
-
End If
-
-
If Dir(PhotoPath) = "" Then ' not found
-
Msg = "Photo: " & PhotoPath & vbCrLf
-
Msg = Msg & "is not found at the above location (or is misspelled)"
-
MsgBox Msg, vbInformation, "Missing Photo"
-
Rpt.Photo.Picture = ""
-
Exit Function
-
End If
-
-
Set MyDb = CurrentDb
-
Set ImageTypeSet = MyDb.OpenRecordset("ImageTypes")
-
-
With ImageTypeSet
-
Do Until .EOF
-
If Right(Dir(PhotoPath), Len(!ImageType)) = !ImageType Then
-
.Close
-
GoTo LegalPhoto
-
End If
-
.MoveNext
-
Loop
-
.Close
-
End With
-
-
Rpt.Photo.Picture = "" ' Not a photo
-
Set ImageTypeSet = Nothing
-
-
Exit Function
-
-
LegalPhoto:
-
Rpt!Photo.Picture = PhotoPath
-
Set ImageTypeSet = Nothing
-
-
End Function
-
You can omit the bit about Image type if you wish. This is a check that the picture is a type that can be displayed. Legal types can be found at
https://msdn.microsoft.com/en-us/lib...(v=vs.60).aspx
Hope this helps
Phil