Image Database Locations

J

Jason Lopez

I have a database where my images are located in a folder outside of the
database. However, I work on the database in two different locations from a
flash drive. In so doing, the drive letters are different. I don't have
the ability of changing the drive letter at one location. So, is there a
way to put the image file location in a format that will search from the
current drive? I currently have the location setup as the following:

<ProjectFolder>
Database.mdb
<ImageFolder>
Image#.jpg

So, the image location in the table looks like this: "F:\Project
Folder\ImageFolder\Image#.jpg"

Is there a way to make that "F:\" more dynamic in a way that I don't have to
specify the drive where the path starts?

Jason Lopez
 
A

Arvin Meyer [MVP]

Break up the path to each file into components. For instance:

Location:
A
B

Drive:
C:\
G:\

Directory:
Images\
Projects\Images\

FileName:
Image#.jpg
Image#.jpg

This method requires multiple entries for each image, but is the relational
way. You could also put all the fields for each in database and easily
update them with a query. It wouldn't be as normalized, but for only 2 or 3
locations, so what. Build a query which returns only 1 drive letter and:

Then you put the data together like:

Me.ImageControl.Picture = [txtDrive] & [txtDirectory] & [txtFileName]
 
R

Rob Parker

Hi Jason,

If your images are always stored in a folder which is in the folder where
the database is located, you could store just that folder path and filename,
and use the CurrentProject.Path to prepend the database folder.

Eg. using the folder names you posted:
Store "\ImageFolder\Image#.jpg" in your table, and use code such as
Me.YourImageControlName.Picture = CurrentProject.Path & Me!ImageFileName
to open the image.


CurrentProject.Path does not include the trailing back-slash on the
pathname, so include that in your location string.

HTH,

Rob
 
J

Jason Lopez

My images are in subdirectories of the main database. The
"CurrentProject.Path" command worked great. Thanks Arvin for the query
option. But, Rob's worked exactly the way I was looking for.

Thanks to both of you for your help.

Jason Lopez
 

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