displaying photos

G

Guest

Does anyone know how to display photos in a report that are related to the
data that are being reported?? In other words, my report is based off a query
that has 50 records in it. ONe of the fields in the query is the path to a
photo for each record. As I create a report for each record, I want the
related photo displayed in the report. Can this be accomplished, and if so
any clues??

Thanks
 
R

Rob Parker

You need code such as this in the On Format (or On Print - see below) event
of the report
section in which the image is to be displayed:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.PictureFilename <> vbNullString Then
Me.imgPicture.Picture = Me.PictureFilename
Me.imgPicture.Visible = True
Else
Me.imgPicture.Visible = False
End If
End Sub

The above assumes that the image is to appear in the detail section, that
the field containing the picture path/filename is called PictureFilename,
and that the
ImageControl is called imgPicture. Change to suit.

[Thanks to Stephen Lebans for this tip regarding using the On Print event.]
If you don't need to change the dimensions of the Image control
then your code is better placed in the Print event of the relevant
section. This will result in less chance of memory/resource issues at
Preview/Print time.

HTH,

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top