photos in reports

G

Guest

I am using a bound field that stores the path to a photo in a file located
outside the database. Photos show up in the form using a image control,
However, Does anyone know how to get them show up in a report using print
preview?.

thanks
 
L

Larry Linson

salmonella said:
I am using a bound field that stores the path to a photo in a file located
outside the database. Photos show up in the form using a image control,
However, Does anyone know how to get them show up in a report using print
preview?.

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.

For reports, the code used in the Form's Current event can be used in the
Detail Section's Print (this one is preferred) or Format event.

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
 
G

Guest

Thanks Larry,

Actually Doug Steele had suggested the tripod site and i have used the code
to get the photos to show up in the form, It is the report preview that is
now the problem.

I am not sure from you note how this is done (very little experience with
reports). It appears you are saying to use the detail section's print event
to put the code. Exactly how is this done? If i have a control called 'link'
that has the path to the picture and an unbound image control called photo,
can you give me the basic syntax of the expression that i would put in the
print event so that photos show up on print preview??


Many thanks!!
 
L

Larry Linson

salmonella said:
Thanks Larry,

Actually Doug Steele had suggested the tripod site and i have used the
code
to get the photos to show up in the form, It is the report preview that is
now the problem.

I am not sure from you note how this is done (very little experience with
reports). It appears you are saying to use the detail section's print
event
to put the code. Exactly how is this done? If i have a control called
'link'
that has the path to the picture and an unbound image control called
photo,
can you give me the basic syntax of the expression that i would put in the
print event so that photos show up on print preview??

Are you comfortable with VBA? Code to do what you want is there in the
example*, but for forms it is in the Current event.

* which I wrote because I'd been typing the same answers over and
over and over and.... <well, you get the idea>

If your control called Link is defined to contain the fully qualified path
and filename of the image, then here's some air code:

If IsNull(Me.Link) = False Then 'Just in case no picture is
specified
Me!Photo.Picture = Me.Link
Then
Me!Photo.Picture = strNoPic 'where variable strNoPic contains
the
'path and
filename of a one or two
'pixel square
white image, or one that
'matches the BG
color of the Report.
End If
 
G

Guest

Hi Larry,

I can handle simple VBA statements such as what is required here- just don't
know where to put them and on which controls

Just to make sure I am not confusing you, I have taken the code from the
tripod site and adapted it for my form and it works great (unless you click
through the picts too fast!). The problem is I have very little experience
with reports and controls.

For example, do I set up the report the same as the form with an unbound
image control who's picture property gets the picture's path from a control
holding the path? if so, when i add an image control to the report the
picture property for the control is not to be found- should it be there? And
do I add anything( and what) to a section's print event property. I am sure
this is a very simple thing, it is just that I have not a clue how to set it
up things in Reports!

Could you walk me through the architecture, what type of controls to add and
where to put the code?

Many Thanks!
 
L

Larry Linson

For example, do I set up the report the same as
the form with an unbound image control who's
picture property gets the picture's path from a
control holding the path? if so, when i add an
image control to the report the picture property
for the control is not to be found- should it be
there?

My Image Control _did_ have a Picture property, under the Format tab of its
Property Sheet. If yours does not, delete it, check to make certain you are
using the Image Control from the Toolbox and follow the steps below to
replace it.

I created a Report referencing tblImageFiles, in the Detail Section of which
I had a control called txtImagePathAndFile, and on which I placed an Image
Control from the Toolbox. I chose a picture, clicked it in, and later
deleted the text from the Picture property. I changed the default SizeMode
value of Clip to Zoom. I changed the wizard-generated name to imgImage. In
the Print Event of the Detail Section, I put the following:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Me!imgImage.Picture = Me.txtImagePathAndFile
End Sub

and it worked just fine.
do I add anything( and what) to a section's print event property. I am
sure
this is a very simple thing, it is just that I have not a clue how to set
it
up things in Reports!

Could you walk me through the architecture, what type of controls to add
and
where to put the code?

Caution: my report had only two Records, each with a JPG picture. Be sure to
check the reference in my original response to Stephen Lebans' site, to
avoid running out of memory if you have quite a number of pictures in JPG or
GIF compressed format.

Best of luck with your project.

Larry Linson
Microsoft Access MVP
 
G

Guest

Larry,
worked just fine. I had made a very stupid mistake, I was using an unbound
object control instead of the image control- This is what happens when I try
to do this between lab work, students, etc.

Thanks for the info on where to put the code and on using a blank photo for
when the path field is null- nice idea!!!

Thanks again!!!
 

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