multiple images in a report

C

Cioffredi

I am pulling multiple jpg images into a report using a Detail Format event
procedure. This works fine but takes forever. Watching the progress window
shows that it imports each picture multiple times upon opening the report as
well as each time I page forward or back in the report. If anyone knows of a
better method or solution, I am all ears. Running Access 2003, VBA code is
below. imgPicture1 is the control name.

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

Dim Path_Name As String
Path_Name = "P:\PR40362\Database Photos\"

On Error Resume Next

imgPicture1.Visible = True
imgPicture1.Picture = [Path_Name] & [Field_Photo_Name] & ".jpg"

'Error message to display if photo not defined
If Err = 2220 Then

imgPicture1.Visible = False

End If

End Sub
 
L

Larry Linson

Using the Print event rather than the Format event will reduce the number of
loads of pictures, but paging forward and backward in Report Preview will
cause pages to be redrawn and there's no "magic bullet" to prevent it.
 
C

Cioffredi

Using the Detail_Print event isn't pulling the photos at all, even when
spooled to a printer. I understand that paging forward and backward will
"reevaluate" each image ... just as long as it does it once vs. multiple
times per picture.

Larry Linson said:
Using the Print event rather than the Format event will reduce the number of
loads of pictures, but paging forward and backward in Report Preview will
cause pages to be redrawn and there's no "magic bullet" to prevent it.

Cioffredi said:
I am pulling multiple jpg images into a report using a Detail Format event
procedure. This works fine but takes forever. Watching the progress window
shows that it imports each picture multiple times upon opening the report as
well as each time I page forward or back in the report. If anyone knows of a
better method or solution, I am all ears. Running Access 2003, VBA code is
below. imgPicture1 is the control name.

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

Dim Path_Name As String
Path_Name = "P:\PR40362\Database Photos\"

On Error Resume Next

imgPicture1.Visible = True
imgPicture1.Picture = [Path_Name] & [Field_Photo_Name] & ".jpg"

'Error message to display if photo not defined
If Err = 2220 Then

imgPicture1.Visible = False

End If

End Sub
 
L

Larry Linson

Using the Detail_Print event isn't pulling
the photos at all, even when spooled to
a printer. I understand that paging forward
and backward will "reevaluate" each image ...
just as long as it does it once vs. multiple
times per picture.

I haven't had similar experiences with the Print event. Unfortunately, by
design, the Format event may fire multiple times for display of each
Record -- there is no way to prevent that. Here are some references to
examples that seem to work for me and for MVP Stephen Lebans. Maybe they
will be of some help.

The sample imaging databases at http://accdevel.tripod.com illustrate three
approaches to handling images in Access, and the download includes an
article discussing considerations in choosing an approach. Two of the
approaches do not use OLE Objects and, thus, avoid the database bloat, and
some other problems, associated with images in OLE Objects.

If you are printing the images in reports, to avoid memory leakage, you
should also see MVP Stephen Lebans' http://www.lebans.com/printfailures.htm.
PrintFailure.zip is an Access97 MDB containing a report that fails during
the Access formatting process prior to being spooled to the Printer Driver.
This MDB also contains code showing how to convert the contents of the Image
control to a Bitmap file prior to printing. This helps alleviate the "Out of
Memory" error that can popup when printing image intensive reports.

Larry Linson
Microsoft Access MVP
 
C

Cioffredi

I will give those two pages a look. Maybe there's a better approach to this.
Always appreciate learning tools. Thanks for your time and responses.

Cioffredi
 

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