Relative Path (?)

LadyDev

New member
Local time
Today, 10:05
Joined
Jul 18, 2003
Messages
5
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\picture.jpg) to the image stored in a text field within the .mdb, but when I distribute the .mdb to others I have (or they have) to change the directory to reflect where the file structure is located on their system.

The file structures are the same; it's the dir that are different.

How can I set up any .mdb so that I can store just the relative path (picture.jpg) in the mdb and not have to change C:\ to F:\ or V:\ etc., when I pass the .mdb to someone else to test.?

Thanks!
:confused:
 
You should try using the UNC instead of a fixed drive. As long as everything is in the same location (\\server\partition\) on a network then this will work.

\\Server\Partition\Directory\Subdirectory\filename.jpg

instead of...

X:\Directory\Subdirectory\filename.jpg

HTH
 
Nothing on a server. These are individual machines. Exactly where do I put this vba code/module. I have about 500 pictures.
 
Allowing the users to store the db and pictures in different locations will make your job a lot harder than it has to be. Why no force the users to have the db and their pictures stored in the same location on all PCs?

C:\ProjectName\Database\YourDB.mdb
C:\ProjectName\Pictures\Picture0001.jpg

HTH
 
I must be saying this wrong. The structure is all the same. The directories are different on some machines. If the individual already has c:\ dir mapped and his next available dir is F:\ they use it.

Someone told me the code was similiar to VB's App Path, but that's all they knew. I haven't been successful at finding anything on either.
 
Why don't you create a new table for local database settings. (IE a table that contains information pertinent to the local user or computer) I normally create a table that stores the local path, backend database name, User Name... (you get the point).

Then once you have a table with the "local" directory for the images you can create a fuction that will return the images with the path.

Example Function that passes the filename from the procedure and returns the full path.

Public Function GetImagePath(FileName As String) As String
Dim DB As Database
Dim RST As DAO.Recordset

GetImagePath = ""

Set DB = CurrentDb()
Set RST = DB.OpenRecordset("tblLocalSettings", dbReadOnly)
GetImagePath = RST!ImagePath & "\" & FileName

RST.Close
Set DB = Nothing

End Function


Depending on how your users install the Database, you can run a form that allows the user to set the image directory the first time they run the database or some other way to fill the correct table information.
 
This function reads more like what I am trying to convey. But where would I place this function. I have been unsuccessful at creating a .mde (.exe for Access) from my db - so I am assuming this is a major problem for me?
 
You would place this function into a module and then call it from a form passing on the filename to search for.

Example.
You are looking up the file c:\Images Directory\Image.jpg.

In the tblLocalSettings table you would have the directory stored as "c:\images directory"

From a form that is searching for the file "image.jpg" and return it to the Variable String called "imagename" you would call this procedure.

imagename = GetImagePath("image.jpg")

This in turn will return the full path of "c:\images directory\image.jpg".

As for Creating a MDE, have you tried running the "Compile All Modules" command before creating the MDE? or is there a specific message that comes up when you try to create one?
 
Okay I think I have it.

No, I haven't run Compile All Modules. Where is that located -- Tools/Make MDE. The warning I am getting simply states (with no other explanation) "Microsoft Access was unable to create an MDE database"
 
you could specify the path relative to the database i.e.:

c:/x/y/z/databasefile-resides-here
c:/x/y/z/pictures folder/

then you can use this variable to specify the pictures folder relative to the database file

CurrentProject.Path & "\pictures folder\"

as long as your database file resides in the same directory as your picture folder, it should be no problem.

so all your guys can put the database file, and the picture folder on their desktop, and go for broke!
 
you could specify the path relative to the database i.e.:

c:/x/y/z/databasefile-resides-here
c:/x/y/z/pictures folder/

then you can use this variable to specify the pictures folder relative to the database file

CurrentProject.Path & "\pictures folder\"

as long as your database file resides in the same directory as your picture folder, it should be no problem.

so all your guys can put the database file, and the picture folder on their desktop, and go for broke!

Welcome to the forum. Did you notice you responded to a thread that was last updated on 7/24/2003? ;-)
 
lol.... i did not, however, perhaps she is still sitting behind her desk pulling out her hair, and hasn't showered since then.... you can never be too careful.... maybe i inadventantly saved her life, and possibly her marriage too.
 

Users who are viewing this thread

Back
Top Bottom