Images on continuous forms

als315
CERTIFIED EXPERT
Published:
Updated:
Very often you need to display images on continuous forms. It could be photos of employees or goods, or other images. You can use attached OLE objects, but they are very whimsical.

You can try the sample in this article:
http://access.bukrek.net/tutorial/continuous-forms
but it is very dependent on your system settings and will not work consistently.

Access 2007 and 2010 give us a modified Image control, which is able to display external images from file paths saved in our records. Advantages of this method are obvious: DB will not grow with each new image, images could be edited and replaced independently.

Let us assume we have a table with a text field containing the full path to an image: tblImagesCreate a continuous form with this field: frmImagesAdd an Image Control to the detail part of your form: image controlWhen asked about the file name, press Cancel.
Open the Image Control's properties:
Image control propertiesYou should set the Control Source to the field with path to images:
Control SourceResult you can see immediately:
form
Now we can make some improvement.
It is a good idea not to store the full path to the image, only the relative path. Using the relative path we do not need to change every record when moving the DB to a new folder or network path. We can add field to our form with path to images (of course it could be field in a table with DB parameters).
If field's name is "path", we can modify control source of our Image Control:
relativeI have added "\" between path to image folder and image name, but you will need to do it only if path is not finished with slash. You can add analysis of path as future improvement.
Included is archive with sample DB and sample images. Unpack all files to one folder and open DB. As you can see there are images in different formats (tiff, jpeg, png) and you can see all images without problems.
ImagesTest.zip
6
11,245 Views
als315
CERTIFIED EXPERT

Comments (3)

this article is very useful to all.

Commented:
Can this procedure be used to display images from a website? (Note: I know the image paths won't change, because it's my website.)
CERTIFIED EXPERT

Author

Commented:
You can't use http://.... path, only some local (d:\....) or network(\\server1\sharedfolder\....) paths. You always should download files from website before you can show it.

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.