Image from table on a report

J

JimP

What is the process for storing an image file (jpg) in a column in a table
and then using the value in a report?
 
J

Jack Leach

You can use an OLE field and store the image, and the use the appropriate
control on the report, BUT there's a much better way.

The problem with storing the image itself is the size of your database, it
will rapidly grow if you have more hand a handful of images.

My (and most people's) preferred method is to store the PATH to the image in
a text field in the table. Then include an unbound image in your report.

Me.MyImageControl.Picture = [mypicturepathfield]

or

Me.MyImageControl.Picture = _
DLookup("fldImagePath", "MyTable", "IDfield = " & [myIDcontrol])


On the unbound control, make sure the picture type is Linked and not Embedded


hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
J

JimP

Thank you,

This is a distributed mdb and users will not have access to the source image
file. The only way I can do this is to somehow save the image somewhere in
the mdb and then have each report reference this object (I think). Note
there are many reports that need to access the image.


Jack Leach said:
You can use an OLE field and store the image, and the use the appropriate
control on the report, BUT there's a much better way.

The problem with storing the image itself is the size of your database, it
will rapidly grow if you have more hand a handful of images.

My (and most people's) preferred method is to store the PATH to the image
in
a text field in the table. Then include an unbound image in your report.

Me.MyImageControl.Picture = [mypicturepathfield]

or

Me.MyImageControl.Picture = _
DLookup("fldImagePath", "MyTable", "IDfield = " & [myIDcontrol])


On the unbound control, make sure the picture type is Linked and not
Embedded


hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



JimP said:
What is the process for storing an image file (jpg) in a column in a
table
and then using the value in a report?


.
 
J

Jack Leach

If the image is not dynamic (won't ever change), then you can just use an
image control on the report and set the image type to embedded, it will save
the image with the report and will be there whenever you distribute the mdb.
Unfortunately if there's a massive amount of reports that need this image, it
will increase your db size, but on the plus size that will be the size of
your FE instead of your BE (assuming you have a split db, preferrably
distributing an mde rather than mdb).

What I generally do in this case is distribute the image file itself along
with the frontend of the application. If you have the means to do this, put
it in the same folder as the frontend, then you can set it to your report
image (a linked image type rather than embedded if you're going to set it
through code) on the reports' open events...

Private Sub Report_Open(Cancel As Integer)
Me.ImageControl.Picture = CurrentProject.Path & "\pic.jpg"
End Sub

If neither of these options work for you I think you will have to look into
an OLE field, but I've never used them so I can't help you with that.

hth

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)



JimP said:
Thank you,

This is a distributed mdb and users will not have access to the source image
file. The only way I can do this is to somehow save the image somewhere in
the mdb and then have each report reference this object (I think). Note
there are many reports that need to access the image.


Jack Leach said:
You can use an OLE field and store the image, and the use the appropriate
control on the report, BUT there's a much better way.

The problem with storing the image itself is the size of your database, it
will rapidly grow if you have more hand a handful of images.

My (and most people's) preferred method is to store the PATH to the image
in
a text field in the table. Then include an unbound image in your report.

Me.MyImageControl.Picture = [mypicturepathfield]

or

Me.MyImageControl.Picture = _
DLookup("fldImagePath", "MyTable", "IDfield = " & [myIDcontrol])


On the unbound control, make sure the picture type is Linked and not
Embedded


hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



JimP said:
What is the process for storing an image file (jpg) in a column in a
table
and then using the value in a report?


.


.
 
J

JimP

Is it possible to store an image in a table field, or on an open form
field - and use the field in a report?

I don't know if this can be done.


Jack Leach said:
If the image is not dynamic (won't ever change), then you can just use an
image control on the report and set the image type to embedded, it will
save
the image with the report and will be there whenever you distribute the
mdb.
Unfortunately if there's a massive amount of reports that need this image,
it
will increase your db size, but on the plus size that will be the size of
your FE instead of your BE (assuming you have a split db, preferrably
distributing an mde rather than mdb).

What I generally do in this case is distribute the image file itself along
with the frontend of the application. If you have the means to do this,
put
it in the same folder as the frontend, then you can set it to your report
image (a linked image type rather than embedded if you're going to set it
through code) on the reports' open events...

Private Sub Report_Open(Cancel As Integer)
Me.ImageControl.Picture = CurrentProject.Path & "\pic.jpg"
End Sub

If neither of these options work for you I think you will have to look
into
an OLE field, but I've never used them so I can't help you with that.

hth

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)



JimP said:
Thank you,

This is a distributed mdb and users will not have access to the source
image
file. The only way I can do this is to somehow save the image somewhere
in
the mdb and then have each report reference this object (I think). Note
there are many reports that need to access the image.


Jack Leach said:
You can use an OLE field and store the image, and the use the
appropriate
control on the report, BUT there's a much better way.

The problem with storing the image itself is the size of your database,
it
will rapidly grow if you have more hand a handful of images.

My (and most people's) preferred method is to store the PATH to the
image
in
a text field in the table. Then include an unbound image in your
report.

Me.MyImageControl.Picture = [mypicturepathfield]

or

Me.MyImageControl.Picture = _
DLookup("fldImagePath", "MyTable", "IDfield = " & [myIDcontrol])


On the unbound control, make sure the picture type is Linked and not
Embedded


hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



:

What is the process for storing an image file (jpg) in a column in a
table
and then using the value in a report?


.


.
 
J

Jack Leach

This can be done using an OLE field, but I do not know the details. Someone
else will have to advise on that, or probably a google for "store jpg in ole
field" would dig up some example or another that you can use

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



JimP said:
Is it possible to store an image in a table field, or on an open form
field - and use the field in a report?

I don't know if this can be done.


Jack Leach said:
If the image is not dynamic (won't ever change), then you can just use an
image control on the report and set the image type to embedded, it will
save
the image with the report and will be there whenever you distribute the
mdb.
Unfortunately if there's a massive amount of reports that need this image,
it
will increase your db size, but on the plus size that will be the size of
your FE instead of your BE (assuming you have a split db, preferrably
distributing an mde rather than mdb).

What I generally do in this case is distribute the image file itself along
with the frontend of the application. If you have the means to do this,
put
it in the same folder as the frontend, then you can set it to your report
image (a linked image type rather than embedded if you're going to set it
through code) on the reports' open events...

Private Sub Report_Open(Cancel As Integer)
Me.ImageControl.Picture = CurrentProject.Path & "\pic.jpg"
End Sub

If neither of these options work for you I think you will have to look
into
an OLE field, but I've never used them so I can't help you with that.

hth

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)



JimP said:
Thank you,

This is a distributed mdb and users will not have access to the source
image
file. The only way I can do this is to somehow save the image somewhere
in
the mdb and then have each report reference this object (I think). Note
there are many reports that need to access the image.


"Jack Leach" <dymondjack at hot mail dot com> wrote in message
You can use an OLE field and store the image, and the use the
appropriate
control on the report, BUT there's a much better way.

The problem with storing the image itself is the size of your database,
it
will rapidly grow if you have more hand a handful of images.

My (and most people's) preferred method is to store the PATH to the
image
in
a text field in the table. Then include an unbound image in your
report.

Me.MyImageControl.Picture = [mypicturepathfield]

or

Me.MyImageControl.Picture = _
DLookup("fldImagePath", "MyTable", "IDfield = " & [myIDcontrol])


On the unbound control, make sure the picture type is Linked and not
Embedded


hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



:

What is the process for storing an image file (jpg) in a column in a
table
and then using the value in a report?


.



.


.
 
J

John Spencer

An alternative if the image is consistently used in one place in many reports
is to build a subreport that contains the image and the use the subreport when
you need the image.

For instance, if reports consistently have a standard report header with a
logo I construct the standard header as a sub-report and then insert the
sub-report in the report header.

Only one copy of the logo is saved and therefore the bloat is minimal.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
J

JimP

Thank you - good idea.

John Spencer said:
An alternative if the image is consistently used in one place in many
reports is to build a subreport that contains the image and the use the
subreport when you need the image.

For instance, if reports consistently have a standard report header with a
logo I construct the standard header as a sub-report and then insert the
sub-report in the report header.

Only one copy of the logo is saved and therefore the bloat is minimal.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 

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