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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Relative Path(?)

Status
Not open for further replies.

LadyDev

Programmer
Jan 29, 2003
86
0
0
US
I am not sure of the terminology, but how do you 'create relative paths' for pictures in a database. Presently I have the full path (c:\my\picture\you.jpg) to the image stored in a text field within the db, but when I distribute the .mdb to others I have (or they have) to change the directory to reflect their system.

So how can I set up any .mdb so that I can store just the (you.jpg) in the db and when I pass it to someone else I don't have to spend an hour or two changing paths?

Thanks!
 
Share the directory the file is located in. The relative path then becomes "\\nameofmycomputer\nameofsharedfolder\whatever.jpg"
and can be accessed from any machine.
 
I can't have everyone having access to the files. And wouldn't that work only if I were on a network?
 
Store your pictures in the same folder as the database, or in a subfolder if you prefer.

At run time, use the CurrentDb.Name property to get the full path of the current database. Just chop off everything after the rightmost "\" character; what's left is your database folder path. Append your "filename.jpg" (or "subfolder\filename.jpg") and you're ready to open the file.

Another alternative is to let the user specify a folder where the pictures are stored. You can save this specification in the Windows registry using GetSetting()/SaveSetting(), so the user doesn't have to specify it every time. Simply append the picture filename to the user's folder name.

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
I am not familiar with the CurrentDb.Name property. Is this similar command in Visual Basic's App.Path in MS Access?


Public Function GetDBDir() As String
Dim sDBName As String
sDBName = CurrentDb.Name

Do While Right$(sDBName, 1) <> &quot;\&quot;
sDBName = Left$(sDBName, Len(sDBName) - 1)
Loop

GetDBDir = sDBName
End Function
 
CurrentDb.Name is actually a shortening of CurrentDb().Name. CurrentDb() is a function that returns a reference to a DAO.Database object. The Name property is the property of the Database object.

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
I don't think I have enough details. Lady dev, are you asking if you can store the pictures directly in the database ? If so, look at the embedded OLE Object under the Data type subject in the Help file. Otherwise, it sounds like you are storing pointers to the graphics file disk location in your database, not the object itself. If this is so,when you say the users have to modify the path, why are they doing this ? Are you moving the files to a different location when you distribute the database and they have to change the path info to deal with this move? If this is so, a setup program for your app would be a good solution so you can handle these one-time issues.
 
The pictures are located in a folder on my hard drive. If I pass the db to someone else, I get a warning stating that &quot;it can not locate c:\mypic\myfolder\whyme.jpg&quot;. The program is looking for the pictures on my machine.

The files folders on other machines are set up similiar to mine. Certain folders are in a particular directiory.

This is where the problem comes in. I have mine setup on F dir; someone (even though they have the same substructure) will have there's setup on C dir and so on.

I am assuming that this CurrentDb().Name is supposed to seek out the .mdb and once located searches for the folders that are ssupposed to be under that .mdb or its' subfolders. not matter where the .mdb is located on any machine

But where in the program do you stick this CurrentDb().Name module?

 
Currentdb doesn't apply. That command tells access to execute its programtics commands against the current database or supplies a pointer to the current database. It doesn't know anything about any files except the currently open database itself.

Let's define a couple of terms
Absolute Path:
C:\SomeFolderOnMYHardDrive
H:\SomefolderOnANetworkServer
Recognized Only by the local machine, be it server or PC.

\\MyComputersName\SomeFolderOnMyHardDrive
\\SomeServerName\SomefolderOnANetworkServer
Recognized by anyone on the network, if they have rights to the share

Your saying you have .jpgs stored outside of Access that could land anywhere. Here are the choices as far as I know:

1) Set up \\SomeServerName\SomefolderOnANetworkServer, give rights only to who needs it, and force your users to store all files there.

2) Have either a setup or maintenance screen where the user can chooses a place to put the data and have your program read the location from data collected via the screen, store it to a string variable and then use the variable when executing commands to manipulate the file.

3) Search the computer system using computer system for the files you want doing a Dir() loop and giving the user the first file it finds that matches some name you supplied. You'd have a pretty slow program, but if you have a small network or could limit the scope of the search in any way it might work.








 
I think there may be some confusion between a relative path and a UNC path. The following are examples of UNC pathnames.

\\MyComputersName\SomeFolderOnMyHardDrive
\\SomeServerName\SomefolderOnANetworkServer

A Relative pathnames is one which starts inside of a directory and goes down from there, and/or uses the &quot;..&quot; diectory to move up to the parent.

At installation time, suppose that you build a directory called &quot;AppDirs&quot; and you have two directories underneath called &quot;Data&quot; and &quot;Images&quot;. If you know the pathname to the database, then the relative pathname to the Images directory would be:
DatabasePath\..\Images

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top