relative vs absolute paths for images

I

ibvalentine

I am doing some experimenting and I am having problems displaying images with
a relative path. In the Northwind sample database (Access 2003), there is an
Employees table that has a field named Photo. The external photos are in the
same folder as the database so just the file name is entered in the table
field (EmplD1.bmp, EmplD2.bmp, etc.). But if I were building a database, I
would want the photos to be in a separate folder, so I created a folder and
named it "Photos" and moved photo files into that folder. Now I returned to
the Employees table and changed the contents to the Photo field to
"photos\EmplD1.bmp." My photos will not display with this relative path. An
absolute path works but not a relative path. The absolute path is as follows:

C:\\Program Files\Microsoft Office\OFFICE11\SAMPLES\photos\EmplD2.bmp
 
D

Douglas J. Steele

As you've found, Access doesn't work with relative paths.

What you need to do is determine the location of the folder and recreate all
of the paths to point to the correct location.

Part of why you can't rely on relative paths with Access is that you can't
be certain of to what the path would be relative! Depending on how you open
the application, the current directory will be different.
 
B

Bob Quintal

I am doing some experimenting and I am having problems displaying
images with a relative path. In the Northwind sample database
(Access 2003), there is an Employees table that has a field named
Photo. The external photos are in the same folder as the database
so just the file name is entered in the table field (EmplD1.bmp,
EmplD2.bmp, etc.). But if I were building a database, I would want
the photos to be in a separate folder, so I created a folder and
named it "Photos" and moved photo files into that folder. Now I
returned to the Employees table and changed the contents to the
Photo field to "photos\EmplD1.bmp." My photos will not display
with this relative path. An absolute path works but not a relative
path. The absolute path is as follows:

C:\\Program Files\Microsoft
Office\OFFICE11\SAMPLES\photos\EmplD2.bmp

When I want a relative path, I use
left(application.CurrentDb.Name, _
len(application.CurrentDb.Name) _
-len(dir(application.CurrentDb.Name)))
and prepend that to the relative path and file I want.
 

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