This example shows how to use a dynamic path to use for rendering images in an image control on a continuous form.

Put the Images directory directly below the database.  There are some sample JPGs from a trip to Niagra Falls with my kids :) 

FilePathName can start with "\" to be relative to current database location.  ie: c:\myDatabasePath\Images\Picture.JPG would be stored as \Picture.JPG and rendered when the form is shown. Path to use is in an unbound textbox at top of form.

The Image control in Access 2007 allows you to assign a ControlSource of a control containing a FilePathName for display, even in a continuous form.

The table t_Images stores ImageID (autonumber), FilePathName (text 255), dtmAdd (date/time), and dtmEdit (date/time). In order to be truly useful, you will need to add and collect more (descriptive) fields for this table.

The form, f_Images has RecordSource = t_Images, and is a continuous form. It uses code written by Ken Getz to Browse for a filename, stores the file path and name, and displays the corresponding image. It is set up to collect JPG files but that can be changed (of course <smile>)

The SizeMode of the Image is --> Zoom
this means the image will be as large as it can and still fit within the control dimensions without distortion

The form also has a couple calculated controls to parse the path and file name and display both

The example data, of course, will not be on your computer, but you can replace the images in the records that are populated and add more. Although Access 2007 touts no database bloat from images, it likes BMP files (which are huge compared to JPG files). The Image control can render more formats than the Bound Object Frame control.

The form header displays the last path you picked files from and becomes the default path for future picks if a record is empty -- if not, the path of the current record is used. When the form is first opened, the default path is the path of the database.

If you wish to set the path to an existing record, simply click "Browse" for that record. If you do not actually change anything, the dtmEdit property is not changed.

The dtmAdd property is populated using a DefaultValue --> =Now() in the table design

The dtmEdit property is updated in the form BeforeUpdate event if the record is not a new record and the FilePathName field has changed.  It can also start with DefaultValue --> =Now() so it can always be used to get the last added or edited record.

~~~~~~~~

28 Aug 2012

I modified the form to always use a relative path if the filename starts with \

I recommend creating a directory called \Images
under the folder for the current database, as in the included example

this way, all the images for the database can be found.

If the user browses to an image somewhere else, you may want to COPY the file to the database's \Images folder, instead of moving it.  this feature is not written

comments are always appreciated, thank you

Warm Regards,
Crystal
strive4peace2008@yahoo.com

Microsoft MVP
remote training and programming

free book, tips, and tools:
http://www.AccessMVP.com/strive4peace

free video tutorials:
http://www.YouTube.com/LearnAccessByCrystal
http://www.YouTube.com/LearnByCrystal

free downloads:
http://www.RogersAccessLibrary.com/forum/long-crystal_forum71.htm

blog:
http://msofficeuser.com/pages/authors/crystal

* (:  have an awesome day :) *



