How do I automatically insert a graphic referenced by the content of a field?

  • Thread starter Thread starter dmiller
  • Start date Start date
D

dmiller

Guest
I'm a relatively new MS Acess user and am attempting to output a form that contains information from an existing Access database as well as a related graphic located on the local disk.

The reference field for the database is a non-reaccuring ID number (1,2,3,4,5, etc) and the pictures in my \graphics\ directory are similarly named. Is there any way to automatically include the appropriate picture in a form generated by Access?

Due to the number of records in the database, adding each picture individually would be nearly impossible and this forum seems to be my best hope of accomplishing this project in a reasonably painless manner.

A slightly more detailed project description:
The database contains a unique ID number, a possibly non-unique label, and about four other columns of related information. The goal is to output all of these, and the picture, onto a form that we've designed.

Thank you in advance for your assistance.
 
place this code behind a form with that you are going to use to display images
create the alternate image in case there is no image.


Function setImagePath()
Dim strImagePath As String
On Error GoTo PictureNotAvailable
strImagePath = Me.txtImageName
Me.ImageFrame.Picture = strImagePath
Exit Function
PictureNotAvailable:
strImagePath = "path\to\nopicture.jpg"
Me.ImageFrame.Picture = strImagePath
End Function

Edit: Call the function with the 'on current' event
My form is based on a query on the table images.
My table has an autonumber ID and txtimagename (50)
you insert the physical address of the image in text image name

This way your images are not in the access table - only the address.
 
Last edited:
Images in Forms

Just as an addition to the thread. Users will get bored waiting for images to load if this is run on a network and the images are stored centrally. Better to give them the option of seeing an image or not. If it is on a single PC then it will work so long as the PC is not running a lot of other apps.
 

Users who are viewing this thread

Back
Top Bottom