add pictures to database access 2002

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to be able to simply click a "Add Picture" button to take me to
"My Computer" so that I can locate a picture of the item for that record in
the database, select the picture and have it then show up in the pre
determined space. Each picture would be different for each record in the
database.
So far I have come up empty handed and frustrated about how to do this, I
posted this question once before, but I think I pretty much worded it wrong
the first time and didnt get the results needed to achive this result.
Any help you can give me will be most appriciated.
Thanks
Robert
 
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.
 
Robert:

You'll find a demo of mine which shows one way of selecting and displaying
images in Access at:

http://community.netscape.com/n/pfx...yMessages&tsn=1&tid=23913&webtag=ws-msdevapps

This demo actually allows multiple image to be attached to a record, using a
simple address list as an example, and displays the images on demand. Only
the path to the image file is stored in the database. To browse to the file
it uses Bill Wilson's freely distributed class module to open the common
dialog.

Ken Sheridan
Stafford, England
 
Ken,

This is very close to what I want. Now pardon my ignorance here, there will
only be one image for each record so how would I make it just automatically
show that one image?
 
Robert:

With a simple one picture per record table you'd have a text column in the
table in which the paths to the image files would be stored. You'd then
include an image control on a form bound to the table and set the Picture
property of the image control to the value of the text fields in the form's
Current event procedure. Note, however, that this can only be done in single
form view , not in a continuous form. The image is loaded into the form in
the form's Current event procedure with:

Me.YourImageControl.Picture = Nz(Me.ImagePath, "")

where YourImageControl is the name of the image control on the form and
ImagePath is the name of the text field containing the path to the image
file. To add a new image to the current record (or change the existing
image) you'd use much the same code as in my demo, using Bill Wilson's class
module once agian:

Dim OpenDlg As New BrowseForFileClass
Dim strPath As String, strAdditionalTypes As String

' amend the following to suit whatever additional file types you want
listed
' when the common dialogue opens
strAdditionalTypes = "Image Files (*.bmp; *.jpg) |*.bmp; *.jpg"

' open common 'file open' dialogue and get path to selected file
OpenDlg.DialogTitle = "Select Image File"
OpenDlg.AdditionalTypes = strAdditionalTypes

' change next line to whatever folder you want common
' dialogue to open at
OpenDlg.InitialDir = "C:\Documents and Settings\Ken\My Documents"

strPath = OpenDlg.GetFileSpec
If strPath <> "" Then
Me.ImagePath = strPath
Me.YourImageControl.Picture = strPath
End If
Set OpenDlg = Nothing

If you are using JPEGs you'll normally get a progress dialogue popping up as
it loads. This can be annoying at best and can crash Access at worst if you
navigate quickly through records. You can suppress it either by a registry
hack or by calling the Windows API at short intervals in the form's Timer
event procedure. For details of these methods see the following link:

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

Ken Sheridan
Stafford, England
 
Hey, Thank you very Much. I think I can figure out how to make this all work
now to suit my needs...
If I get hung up and stuck, can I email you for advice?

Robert
 
You can reach me at:

ken<dot>sheridan<at>dsl<dot>pipex<dot>com

Ken Sheridan
Stafford, England
 

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

Back
Top