PDA

View Full Version : Solved: Help with images on a report



boneKrusher
05-06-2006, 05:56 AM
I am having trouble printing my images on a report. The report is linked to a query. The problem is that its only printing the last image on record. Here is my code.

Thanks for the help.

Code:


Private Sub Report_Activate()
Dim pathx As String
Dim Loc As String
Dim nm As String

pathx = Me.Application.CurrentProject.Path
Loc = pathx & Me.Imagepath
Me.Text12 = Loc
Me.imagetest.Picture = Loc


End Sub

OBP
05-06-2006, 07:05 AM
If this is Access why are you using VB when the normal Table/query/Report can handle the inclusion of pictures/objects without any hassle at all?
Is it for the practice or to learn how?

boneKrusher
05-06-2006, 12:15 PM
I have photos attached to each record. When the user prints the report, I want the photos related to that record only to print out. How do I do it?


Thanks

OBP
05-06-2006, 01:09 PM
How are they "attached" to the records?
Are they stored in the table as photos or as "Icons" (package).
Icons can only be displayed by the original photo software package.
Are you using a text field to hold the path to the photo, which requires VB to make it work?
For a text box with the full path to the photo, this in the Details "Format" Event procedure works for me -


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo err_Detail_Format

If Not Me!fieldname = "" Or Not IsNull(Me!fieldname) Then
Me!Picture.Picture = Me!fieldname
Else
Me!Picture.Picture = ""
End If

exit_Detail_Format:
Exit Sub

err_Detail_Format:
MsgBox Err.Description
Resume exit_Detail_Format

End Sub


where Picture is the name of the image control.

Edited 9-May-06 by GeekGirlau. Reason: Insert vba tags

boneKrusher
05-07-2006, 02:57 PM
Me.imagepath holds the link location (c:\temp\photo1). The command
Me.imagetest.Picture displays the photo.

.....?

OBP
05-08-2006, 02:25 AM
I think I see the problem, you have the VB code in the "Report Activate" event procedure, as I stated in my previous post it has to go in the
Detail's "On Format" event procedure.

boneKrusher
05-08-2006, 04:07 AM
That was it! Thank you so much!

geekgirlau
05-08-2006, 06:41 PM
BoneKrusher, don't forget to mark the thread "Solved" using the Thread Tools at the top of the page.

boneKrusher
05-09-2006, 05:34 AM
Ok will do.