Change image for each record (need loop help)

M

mallarym

I have a database with a picture for each person. The filepath is stored in
the table and want to print a report with each person's info/picture. I put
a blank image on the report and can get it to change for the first record.
However, I need help with a loop that will get it to change for each.

I have it as a function because there are multiple pictures and I am using a
macro to call all the functions.

I need help with where to call the macro from. I have tried it from onOpen
from the Report and in the detail section onFormat. Also need help running a
loop. Here is my code:



Public Function Pic1Change()

Dim rstPic1 As Recordset
Set rstPic1 = CurrentDb.OpenRecordset("select [tblPeople].pic from
[tblPeople]")

Dim Pic1path As String
Pic1path = rstPic1!Pic

On Error GoTo Pic1NotAvailable:
Reports!MainReport.Pic1.Picture = Pic1path

GoTo Exit_this


Pic1NotAvailable:
Err.Clear
Reports!MainReport.Pic1.Visible = False
Reports!MainReport.Pic1Error.Visible = True
Resume Exit_this

Exit_this:
End Function



Thanks!
 
Top