Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with relative filepaths!

Status
Not open for further replies.

Entrepenueress

Technical User
Aug 12, 2002
16
US
I have written a database that creates a photo directory of people for our church. Right now each record points to a photo that is kept in the same folder as the .mdb file. This folder gets passed on from person to person as time goes on. Instead of having to make them use a set file path, I wonder if there is a way to reference the pictures with a relative filepath like in a web page so it will automatically just point to the same folder that the .mdb file is in (instead of a fixed file path).

Any ideas?
Thanks!
 
Are you developing using VBA?

You could use a global variable to set the path. As the application opens, pass the path location into the variable like this:

gstrPath = CurDir

That way the variable will store whatever path the MDB is located in. Then when you referenc the picture, it's path will be:

gstrPath & "\Image.jpg"

Of course you can ignore the globale variable altogether and just do:

CurDir & "\image.jpg"

Birklea

birklea ~©¿©~ <><
Dim objJedi as Jedi.Knight
Set objJedi[skyWalker].Aniken = FatherOf(useThe.Force(objJedi[skyWalker].luke))
 
Hi birklea,

Entrepenueress might have problems using the CurDir Function as it reports the &quot;Default Database Folder&quot;.

I think it might be best using:

Access 97

Dim Cdbs As String, dbs As String, strPath As String
On Error Resume Next
dbs = &quot;YourDBName.mdb&quot;
Cdbs = CurrentDb.Name
strPath = Left(Cdbs, InStr(Cdbs, dbs) - 2)
MsgBox strPath


Access 2000+

Dim strPath As String
On Error Resume Next
strPath = Application.CurrentProject.Path
MsgBox strPath

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top