Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple images on a Report

Status
Not open for further replies.

RonMcIntire

Technical User
Oct 12, 2002
166
0
0
US
All:
I wish to put up to 11 images on an Access Report from data in one Table.
The number of fields include ID, Org, FName, LName, Office, OfficerName, and FilePath (to the image).
I create my Table with a form, inserting single images for each name, and show the image in an image box.

I considered creating queries but its a lot of work because I have to add the query name with the field (I think).

My Problems is:
I am lost when it comes to putting multiple image on one report.
Any help to get me started would be appreciated.
Ron Mc
 
It seems you have only a single image path in each record. I have used code in the On Format event of the report section to set the picture property of the image control.

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If Len(Dir(Me.FilePath ) > 0 Then
        Me.imgPhoto.Picture = Me.FilePath 
        Me.imgPhoto.Visible = True
     Else
        Me.imgPhoto.Visible = False
    End If
End Sub

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
dhookom
Thanks for your response.f
I understand what you're saying, but I have 13 images paths in one table I want to put on one report. I haven't figured out how to make your code work for me.

I think I want to step through my table (field, Org) and pick up the file path in that record, but I need a little help in doing it. When I choose any Org number, it gives me FilePath from Record 1 each time. I have named each field on the form nFilePath1, nFilePath2, etc.

Hope I've been clear. The key sentence is sentence one of this post.
Ron
 
Do you have 13 records each with one image path or does each record have 13 image paths? You would need either one image control or 13.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Each record has one image. There are 13 records in the table.
 
I tried to edit my post yesterday and found it didn't send so here is what I have so far:

dhookom
Thanks for your response.
BTW: I am using Office 2007 and Win10
I understand what you're saying, but I have 13 images paths in one table I want to put on one report. I haven't figured out how to make your code work for me.

Here's what I have so far. It works down to the three items in red, then hangs up. I keep getting a message that says, "You have a macro that didn't execute, but I haven't found it yet.

Question: Will the three items marked in red work in Detail_Format?

The three red items are:
nFilePath Image Name
FPath( ) FilePath Field data


Public Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Dim i As Integer
Dim db As Database
Dim rs As Recordset
Dim FPath(13) As String

Set db = CurrentDb
Set rs = db.OpenRecordset("tblChapter Officers")

For i = 0 To rs.RecordCount - 1
'nFilePath1.Picture = FilePath
FPath(i) = rs.Fields("FilePath")
rs.MoveNext
Next

Me.nFilePath1 = FPath(0)
Me.nFilePath2 = FPath(1)
Me.nFilePath3 = FPath(2)


db.Close

End Sub

Ron
 
Is the report bound to "one Table"? If not, can you explain why you wouldn't set the record source to the table or a simple query based on the table?

Is there a particular layout you require for the images like a grid or just in a single column?

Is nFilePath1 an image control? If so, you need to reference the Picture property.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
I've bound the table to a single record source: tblChapter Officers

Eleven of the images are in a w x 3 grid and two images are at the top of the grid, like this:
x x
x x x
x x x
x x x

Each image has a name: nFilePath1, nFilePath2,. . . . nFilePath11. The remaining two images are used in another Report but were included for test purposes. I'll use them when I get a solution to this problem.

Ron
 
I didn't answer your question: I have tried putting FPath(1), nFilePaath1, and FilePath for each image in the Detail Picture Property name field. No Luck.
 
You can create a three column report with the report width set to about a third or less of your page width. Use a single image control with the control source set to the full path to your picture file.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Why would I want a 3-column report when I have all my images in a grid? Please look at my code procedure to see if I'm doing anything wrong that would cause my program to hang up. I'm sure I haven't assigned the image controls (in red) correctly.

The images are in a grid like this:
x x
x x x
x x x
x x x

Ron
 
You can simplify this with no code and just one bound image control in a multi-column report. If you want to use code then I would confirm the file paths are stored properly in the array and then change your code to reference the Picture property as suggested a couple times:

Code:
Me.nFilePath1.Picture = FPath(0)
Me.nFilePath2.Picture = FPath(1)
Me.nFilePath3.Picture = FPath(2)
You could also use a loop. I think this would work:
Code:
From I = 1 to 11
    debug.print i, FPath(i-1)
    Me("nFilePath" & i).Picture = FPath(i-1)
Next

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
dhookom

Looks like I have found the solution. I now have to figure out how to handle the arguments for the Detail section.
Thanks for your help.
Ron Mc
 
I’m not sure I know what you mean by “ arguments for the Detail section”.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top