problem with inserting images in Access report
Hello everyone,
I have a really weird problem while insering images in an Access report.
I have a table where one of the rows contain path to an image on the disk. This may also be NULL, in which case I do not want to show an image.
In my report, I added an Image control and used the detail section event handler as follows:
The Me.Photo refers to the control source that gives me the path.
Me.Image32 is the name of the image control in the detail section.
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Not IsNull(Me.Photo) Then
If Len(Dir(Me.Photo)) > 0 Then
Me.Image32.Picture = Me.Photo
Else
Me.Image32.Picture = ""
End If
Else
Me.Image32.Picture = ""
End If
End Sub
Now, something very stange happens. My table contains 6 ecords. The first 2 have NULL values for the photo and this handles that properly.
Then I have a valid image, this is also handled fine.
Then I have 2 invalid paths followed by another NULL value. What happens is that the valid image is shown on all of those rows!
So, it seems as soon as one valid image is hit, the picture property just gets set to that! It is really bizarre...
I do not know what I am doing wrong. If someone has any ideas, please help!
Cheers,
Pankaj
|