View Full Version : Image Changes with report


hamrthroer
04-20-2009, 09:18 AM
I have a report that pulls up an individuals information from a query. I have a folder where images of these individuals are stored. I need to link up their image with the rest of their information on the report. The report prompts the user for an ID #. This ID # is the also the file name of their image (12345.jpg). I am a newbie so please be gentle.

ted.martin
04-20-2009, 10:23 AM
This should work: in the report

Private Sub Report_Open(Cancel As Integer)
Me.OLEUnbound0.Picture = "C:\Users\Ted\Pictures\Smudge\Smudge1.JPG"
End Sub

Except - use your own file path and picture name.

ps Smudge is my cat!!!

statsman
04-21-2009, 02:43 AM
You could also add a new field to your individual's table. Make it an OLE Object.
With the table in design view, right click the OLE for each individual and provide a link to the picture. You can add the picture to your forms and reports the same way you would add any other field.

hamrthroer
04-21-2009, 04:17 AM
Thank you for your replies I am going to work with them today. What I'm really stumped about is the fact that the image.jpg will change every time the report runs. In the query there is a field with a unique identifier that will match the .jpg that identifies the individual (example: 12345 would be the unique identifier and the jpg would be titled 12345.jpg). I have a perimeter set up in the query that will prompt the user for this unique identifier. What my aim is is to somehow link up the .jpg with this unique Identifier on opening the report. Other users will be using this report and I have them saving the image to a folder on the server so using your suggestion statsman is there a way to automate the adding of the link? I am studying another database we have that uses a hyperlink but it has so much extra code I am having difficulty sorting out what I need and don't. Thanks again for your time!
Hamr

Simon_MT
04-21-2009, 07:54 AM
You could create a SubReport using the Field containing 12345 to link the Parent and the Child Forms.

Simon

hamrthroer
04-21-2009, 11:27 AM
This report is being generated using a command button. I tried this from another thread.
I have a Module with this code in it:

Option Compare Database

Public Function GetPic(DOC As String)
On Error Resume Next
Dim mypath As String
Dim MyFile As String
'Path were pictures are stored
mypath = "X:\ID List\Images\"
'Change file extn to those of stored images
MyFile = [DOC] & ".jpg"
MyPic = mypath & MyFile
End Function

In the report I an unbound picture object named MyPic and I have this code in the report on the on format event

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
MyPic.Picture = GetPic(DOC)
End Sub

When I run the report it runs but nothing shows up.

I would like to try the sub report but there is no source for the .jpg in the database only a folder with the pics in it which are named the unique ID.jpg.

8 hours at this and ready to give up programming.

Thank you for your efforts

Simon_MT
04-21-2009, 12:02 PM
This is how I do it:

All Functions in an Image Module:


Function GetImageDir() As String
GetImageDir = "X:\ID List\Images\"
End Function


Then on the subReport Detail OnPrint =GetPicture()



Function GetPicture()
Dim FullPath As String
With CodeContextObject
FullPath = GetImageDir & .[Image File]
If Dir([FullPath]) <> Empty Then
.[ImageControl].Visible = True
.[ImageControl].Picture = FullPath
Else
.[ImageControl].Visible = False
End If
End With
End Function


On the Subreport there are two controls

1) Image File derived from a Query Image File: [YourReference] & ".jpg"
2) Image Control


Simon

hamrthroer
04-21-2009, 12:22 PM
I follow all but
1) Image File derived from a Query Image File: [YourReference] & ".jpg"

I know this seems elementary but what is a query image file?

Simon_MT
04-21-2009, 02:03 PM
You declare the Image file within a Query and then the DFunction concatenates the Path and File within the Function.

Sorry I wasn't clear enough.

Simon