In my dataset for an SSRS report, I have a column that is comprised of a path and a file name of an image, dynamically created by each user's user id, as that's how the images for their pics are stored. While that string gets constructed for every record in the dataset, that doesn't mean there is a pic in the UNC file path.
If I set the tablix cell to an image, and then set the properties to external and to that field, I will see the pics for each record, but if there was no image found for some of them, a red x will show. It looks ugly. I wanted to substitute a default pic if the image is not found. I was searching for this and Microsoft CoPilot suggested this VB code be put on the report settings:
Public Function GetImagePath(ByVal filePath As String, ByVal fallbackPath As String) As String
Try
If System.IO.File.Exists(filePath) Then
Return filePath
Else
Return fallbackPath ' Return a default image if not found
End If
Catch ex As Exception
' In case of any error, return fallback image
Return fallbackPath
End Try
End Function
Then for the image, I'm supposed to put =Code.GetImagePath(Fields!ImagePath.Value,"file://///server/folder/defaultimage.png")
but when I do that, every record shows the default image, even when the image from the ImagePath exists. Any idea why this isn't working? I feel like I'm so close to getting what I want it to show. I can either get the images that exist showing for the records where the file is found, and an ugly red x for the records where the images aren't found, or I get the default image for every record.