Adding Photographs to a database table

J

justphilip2003

I am attempting to add photos to a table in a Access 2003 database operating
under Vista Home Premium. In the past never had any success using OLE and was
forces to use Picture It (not an option now). I also receive the not license
to use ActiveX message.

I would appreciate know the proper steps required to add photos to a table
using the OLE/ActiveX method. I scan the code in this link but felt it might
not apply to specific problem.

http://www.mvps.org/access/api/api0001.htm

It also would be nice to be able to add the photos using an existing Form
that I could never get to work. TIA JP
 
R

Roger Carlson

I would never add photos to a database as an OLE object. I would leave them
in the file system (which is better equipped to handle them), store the path
to the picture, and just display it at run-time.

On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "Picture.mdb" which illustrates how to do this. There's
another called "PicturesLoad.mdb" which uses the API code you mentioned to
load the paths into the database.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
L

Larry Linson

justphilip2003 said:
I would appreciate know the proper steps required to
add photos to a table using the OLE/ActiveX method.
I scan the code in this link but felt it might
not apply to specific problem.

http://www.mvps.org/access/api/api0001.htm

It also would be nice to be able to add the photos using an existing Form
that I could never get to work. TIA JP

The sample imaging databases at http://accdevel.tripod.com illustrate three
approaches to handling images in Access 2003 and earlier, 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.
(Access 2007 has enhancements that eliminate the bloat for OLE Objects, but
not necessarily other drawbacks.)

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.

As to using an existing Form that you could never get to work, it would
require psychic powers on our part to offer suggestions about a form
regarding which the only things we know is that it didn't work and that
you'd like to use it.

Larry Linson
Microsoft Access MVP
 
J

justphilip2003

Hi Roger,
Thanks for the ifnformation and your source library. I was able to
incorporate PicturesLoad.mdb logic into my database and can add links to my
picture file. It Worked beautifully. I have not yet been able to code a view
only Form. I reviewed both Pictures.mdb and PicturesLoad.mdb logic for this
purpose and failed to see the proper path. I also noted that every time I
closed the add a picture form and then opened to insert another, the form
always starts counting from 1 and yet the table index is always corect. Is it
possible to show the next index number rather than always startin at 1? I am
weak in the procedure area especially in the copying from one db to another.
Thanks again for your kind assistance. JP
 
J

justphilip2003

I used the logic suggested by Roger Carlson and written by Ken Getz in a
procedure named modOpenSaveFile to locate and store the file name in a field
of one of my tables. At this moment I have not attempted to use the
ImagesA2K example with shortName & ImageName (one step at a time); my table
entries contain the full length File location with each picture file name.

I am seeking a compatible procedure that will retrieve the filed picture
link and display it in a form. Purification will come with understanding. I
am also thinking I would benefit from purchasing a mid level Visual Basic
Developers Handbook if such an animal exists – any recommendations? TIA JP
 
S

SusanJane sjl

Roger,

I have read several solutions to this problem, but yours was the only one I
could understand. I download the Pictures database and got mine to to work,
with one exception. If the picture is not found, I get an error message, and
the previous picture shows up. How can I erase the previous picture & just
have nothing displayed? This is my code:
Option Compare Database
Option Explicit
Dim filename As String, pathname As String
Dim db As DAO.Database


Private Sub Form_Activate()
'find the path of the current database
'which is where the jpegs are stored
Set db = CurrentDb
filename = db.Name
pathname = Mid(filename, 1, Len(filename) - Len(Dir(filename)))

End Sub

Private Sub Form_Current()

'set the picture path
Me.Image6.Picture = pathname & Me.ImagePath
Exit_cmdClose_Click:

End Sub
Private Sub close_Click()
On Error GoTo Err_close_Click


DoCmd.close

Exit_close_Click:
Exit Sub

Err_close_Click:
MsgBox Err.Description
Resume Exit_close_Click

End Sub
 

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