refresh image control

  • Thread starter Thread starter anna_717717
  • Start date Start date
A

anna_717717

Hi all,

I've got an image control on a form. I've used the on current event to set
the picture using the filename held in a subform. This works ok when the form
opens. How can I make the image change when I select a different record in
the subform?

Thanks
 
Hello Anna,

The general answer is to store the path and file name of the picture in 1 or
2 text fields, and then use code to display the image for the record.

Regarding your particular case, you haven't really told us anything except a
few thoughts about a method that doesn't work.
 
Hi,
I've used the following code to set the image control:

Private Sub Form_Current()
Me!ImageToDisplay.Requery
If IsNull(ImageToDisplay) Then
Me!ImageFrame.Visible = False
Else
Me!ImageFrame.Picture = Me!ImageToDisplay
If FileExists(ImageToDisplay) = True Then
Me!ImageFrame.Visible = True
Else
Me!ImageFrame.Visible = False
End If
End If
End Sub

where ImageToDisplay=[frmImages].[Form]![ImagePathName] &
[frmImages].[Form]![ImageFileName]
where frmImages is the subform

When the form opens it displays the correct image but that image does not
change.
How can I get the image to change when I select a different record on the
subform and therefore change the ImageToDisplayControl

Thanks
 
Anna,

I'm not good / fluent enought at code to quickly critique your code.

There have been many good posts in this forum (including "forms forum" over
the last 2 years that I've learned from.

But yours looks very differetn and much more complicated than all of the
others.

I have a form which has a picture which works as you describe and it's just
the following one line of code in the "on CUrrent" event of the form:
("PicturePathAndFile" is a field with that in it, "image17" is the name of
the box )


Private Sub Form_Current()

Me.Image17.Picture = Me.PicturePathAndFile

End Sub
 
Back
Top