Relative Path does not work for displaying JPEG Images

J

John Miller

I am new to Access and know little about VBA Code, but I have a DB with >2000
records and each one needs a different JPEG. I cut and pasted the VBA Code
form the MS Northwind example. I then tested it using some pictures, some
were Absolute pathe, some were in the same dir as the DB and the rest one
directory deeper so I used relative path (sspics\picture.jpg). When I open
up the form to use it the images that are Absolute Path or in the samer dir
as the DB show up just fine, but the relative path ones do not.

If I go to Form design mode reselect a Picture in the ImageFrame Properties
Box (ir forces you to select a picture using absolute path), and then save.
All the images start to work, incliding the relative path ones. That is
until you close the DB and reopen it.

Any ideas, suggestions on how to fix this? It's as if it cannot resolve the
path of the DB so relative path does not work or something.

BTW, In the MS Example on how to do this
(http://support.microsoft.com/default.aspx?scid=kb;en-us;285820), I followed
all the directions, but in the section on using the custom function in a
form, they tell you to point to a picture for the "Picture" property.... what
is the purpose of this, as this is not the one ever displayed, the one from
your record in the DB is what is displayed?

Image Control
---------------------------------
Name: ImageFrame
Picture: "C:\Windows\Zapotec.bmp"

Does it matter what this picture is or where it is?

Thanks to anyone that can assist a VBA Clueless person to get this solved.

John Miller
 
M

Mark Hone

Hi John,

I don't think you can use relative paths as such. You need to work out
where you are and supply your code with the complete path. You can do this
by using the Access object model as follows:

myPictureFileName = Application.CurrentProject.Path & "\sspics\picture.jpg"

Hope this helps,

Mark
 

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