db using photos - where to keep the photos

G

Guest

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.
 
G

Guest

Hi Steve - don't take this the wrong way but were the pictures already linked
when you altered the location? If so, have you re-linked them.
 
B

BruceM

The issue isn't really with the C: drive, but rather with network drives.
If this database and the photos folder are to reside on your local hard
drive I see no problem with referring to c:\images in your link. For
network drives you would use what I believe is known as the Universal Naming
Convention, or UNC. If you insert a hyperlink and drill down through
Network Neighborhood you can see the exact path.
As to not storing them in the database, that is correct. For reasons that
have been discussed extensively elsewhere, the database bloats out of
proportion to the size of the images.
 
B

bob

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.
 
G

Guest

dear all - thank you so much for your input. i am looking forward to
implementing this into my db. it's a rather high profile project that i have
taken on for another dept in my organization. since this is my first
experience using images as such it's a little confusing but i will wade
through all the info you folks have shared and hopefully get this going.
--
Thanks,
Steve D


bob said:
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
 
B

bob

You'll probably also want to take a look at this article to avoid the 'Loading Image' dialog and the crash
that goes with it:

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

--
_______________________________________________________
DBPix 2.0: Add pictures to Access, Easily & Efficiently
http://www.ammara.com/dbpix/access.html


=?Utf-8?B?U3RldmUgRA==?= said:
dear all - thank you so much for your input. i am looking forward to
implementing this into my db. it's a rather high profile project that i have
taken on for another dept in my organization. since this is my first
experience using images as such it's a little confusing but i will wade
through all the info you folks have shared and hopefully get this going.
--
Thanks,
Steve D


bob said:
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==?= said:
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.
 

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

Top