Image Frame Problem on Report - If Null it displays the image from the last record? (1 Viewer)

manix

Registered User.
Local time
Today, 17:25
Joined
Nov 29, 2006
Messages
100
Hi All,

I have a really frustrating problem. I have a report that simply shows a list of records. The records contain file paths for images for various forms and reports within the database.

There are two fileds in each record for the file paths, [Photo] and [Photo2].

In order that the images are displayed with the records I have created 2x image frames and added the following code to the report:

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Not IsNull(Me.Photo) Then
    Me.imgframe3.Picture = Me.Photo
End If

If Not IsNull(Me.Photo2) Then
    Me.imgframe4.Picture = Me.Photo2
End If
End Sub

This works fine if the [Photo] and [Photo2] both have file paths, but if there is nothing in [Photo] or [Photo2], then it simply takes the file path from the last record that did have a path in and displays the image from that, completely unrelated record!!! Why is that happening?

In other words if no file path exists for a record, then the report shows the image from the previous record, even though they are not related in anyway!? :confused:
 

Simon_MT

Registered User.
Local time
Today, 17:25
Joined
Feb 26, 2007
Messages
2,177
I think you need to add what to do when there is no photo, basically you need to clear the imgframe so that there is no reiteration of the previous image:

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Not IsNull(Me.Photo) Then
    Me.imgframe3.Visible = True
    Me.imgframe3.Picture = Me.Photo
else
    Me.imgframe3.visible = False
End If

If Not IsNull(Me.Photo2) Then
    Me.imgframe4.Visible = True
    Me.imgframe4.Picture = Me.Photo2
else
    me.ingframe4.Visible = False
End If
End Sub

Alternatively you could set the imgframes = null on the else

Simon
 

manix

Registered User.
Local time
Today, 17:25
Joined
Nov 29, 2006
Messages
100
I think you need to add what to do when there is no photo, basically you need to clear the imgframe so that there is no reiteration of the previous image:

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Not IsNull(Me.Photo) Then
    Me.imgframe3.Visible = True
    Me.imgframe3.Picture = Me.Photo
else
    Me.imgframe3.visible = False
End If

If Not IsNull(Me.Photo2) Then
    Me.imgframe4.Visible = True
    Me.imgframe4.Picture = Me.Photo2
else
    me.ingframe4.Visible = False
End If
End Sub

Alternatively you could set the imgframes = null on the else

Simon


Thanks Simon......You would have thought that yes, but no, it is still happening! It seems like the [Photo] and [Photo2] fields are being populated by previous records if they are blank!? Otherwise, with the code above, surely they would not be visible!?
 
Last edited:

Simon_MT

Registered User.
Local time
Today, 17:25
Joined
Feb 26, 2007
Messages
2,177
Then I would suggest that you put your function on the Detail but On Print. I would still keep the script intact. I use a Sub Report place the image onto the main Report.

Simon
 

Users who are viewing this thread

Top Bottom