If you use a relative path then you can access the database via a local drive, UNC path or mapped drive
and it will always find the images. You can also move the database and will not need to change anything
(as long as the images move with it). If you need to move the images independently of the database then
you only need to modify the code in one place, rather than changing the path stored in every record. Since
you are not storing duplicated data (the path) in every record the data is better normalized.
This code assumes that the image files are stored in a subdirectory images relative to the location of
the mdb file.
Private Sub Form_Current()
Dim Path As String
Path = CurrentProject.Path & "\images\" & Me![Filename]
If Me![Filename] <> "" And Len(Dir(Path)) > 0 Then
Me![PicCtrl].Picture = Path
Else
Me![PicCtrl].Picture = ""
End If
End Sub
Filename = name of field containing image filename (eg 1234.jpg)
PicCtrl = name of an image control on the form.
This code is intended for Access 2k and later. For earlier versions an alternative method must be used
to get the path to the database.
--
_______________________________________________________
DBPix 2.0: Add pictures to Access, Easily & Efficiently
http://www.ammara.com/dbpix/access.html
"=?Utf-8?B?U3RldmUgRA==?=" <(E-Mail Removed)> wrote:
>all my records will contain photos of the product. it has been suggested to
>me that it would be better file management to put all the images in folder
>underneath the application folder.
>
>That's the concept - don't store the image in the database but rather the
>"relative" path to the image. You don't want to store an absolute path like
>"c:\images" - this will break if you move the database and that directory
>doesn't exist.
>
>Instead make the folder under the folder where your app runs. i have done
>this but the images do not appear in the form when i open it.
>
>need some extra help.
>--
>Thanks,
>Steve D