Link an Image to a field

M

masremi

Hello !

I have a Field "Item" on a report and I would like to show the image of the
item.
There is not the path on a field, but the path is still the same only the
name of the item change.

So what I want is to add an Image control on the report and write the
information :

Image1.Picture = "C:\My pictures\" & [item] & ".jpg"

That is about what I would ... in that way the image should show the item on
a picture.

Someone could explain me how to obtain that result ?

Thank you.
 
S

Sam Davis

Assuming the image file "C:\My pictures\" & [item] & ".jpg" exists then
simply add your line of code to the Print event of the section where the
value of the field [Item] changes.

However, if your folder is supposed to refer to the user's Windows "My
Pictures" folder then it won't work. You'll need code to find this folder as
it will be different for each user. You'll need a function that uses
SHGetFolderPath (from memory) to determine the precise "My Pictures"
directory. Search for SHGetFolderPath...

HTH
Sam
 
M

masremi

Hello !

Don't worry fo the path, it is just an example !

On the print event ... nothing hapen !

The field [item] and the control "Image are on "headgroup0"

If I put the code on the "click" it is working ... but it puts the same
picture on all the control "Image" instead change it only in the row where I
have clicked.

Could you write a code to explain me which private_sub and Event should I use.

Thanks.
 
M

masremi

Hello!

I have risolved ! I have done a new report and it works using the event
"format"

Private Sub Détail_Format(Cancel As Integer, FormatCount As Integer)
Dim strPath As String, strImage As String
strImage = [item]
strPath = "c:\my pictures\" & strImage & ".jpg"
On Error Resume Next
Me.Image3.Picture = strPath
End Sub

Thanks for the help !
 

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