Relative path?

  • Thread starter Thread starter marvet95
  • Start date Start date
M

marvet95

Guest
I'm trying to use relative path in a table to display pictures onto a form. I'm using access 2002 and got it to work once but now doesn't seem to want to work. I might have been displaying them as hyperlinks the first time. Can anyone tell me if they know for certain if Access 2002 supports relative paths (..\Images\Image one.bmp) or do I have to use the hard path (C:\Documents and Settings\My Documents\Images\Image one.bmp)

Thanks for any help.
 
My main reason for wanting to use relative path is so If I have to move my database I can always move my picture folder along with it and have it work.

Well, not sure if this is the best way, probably the cheeseyist though. I put this in the OnCurrent event of my form:

On Error Resume Next
path = "F:\My Images\SHAPES\"
Me![ImageFrame].Picture = path & Me![ImagePath] & ".bmp"

This way if I move the database I only have to change what path equals to in the code. This doesn't seem like the best way to do it but I new to VB and coding. If anyone has any help I would really appreciate it.

Thanks
 
Marvet95,

I'm not sure what version of Access you are using, but in Access2000 you have the CurrentProject object and it has a method called Path.

So if you use
Code:
CurrentProject.Path

it will give you the full path to where the database is being run from. So if you make your images folder a folder within that path then all you'd have to do is concatonate on the rest of the directory structure to get to your images
Code:
Me![ImageFrame].Picture = CurrentProject.Path & "\" & Me![ImagePath] & ".bmp"

You have to add the "\" into the concatonated string because the path doesn't return the trailing \. If you include it in the ImagePath then you don't need to add it in the concatonation.
 

Users who are viewing this thread

Back
Top Bottom