Trying to find a file on a network drive

B

Bruce

I have inherited a database that has a list of image files in the database
but the actual files are located in various places on 3 different network
drives, I am looking for a simple way to locate and pull up the file that the
database was designed to query, but not tell you where it was located.
 
D

Dirk Goldgar

Bruce said:
I have inherited a database that has a list of image files in the
database but the actual files are located in various places on 3
different network drives, I am looking for a simple way to locate and
pull up the file that the database was designed to query, but not
tell you where it was located.

I'm not sure what the situation is. Does the information in the
database contain the actual path to the file or not? If you've got the
path, displaying the picture in an image control or opening it in the
registered application for that file type are both pretty easy things to
do. If you only know the filename without any idea where to look for
it, that's quite a search process to go through, but maybe the
Application.FileSearch object would be useful. If you need to look in
only three possible folders, that's a lot simpler.

If you'll clarify the details, we can probably give more specific help.
 
B

blobber

The database only contains the file name not the directory path. That is
really what I am looking to try and query somehow. Ideally they would just
click on the file and it would go find the file, open it and display.
 
O

Ofer

Mybe, try help in access about "FileSearch Object", it might give you what
you looking for
 
D

Dirk Goldgar

blobber said:
The database only contains the file name not the directory path.
That is really what I am looking to try and query somehow. Ideally
they would just click on the file and it would go find the file, open
it and display.

Can you narrow down the number of places that have to be searched?
Searching every folder on every drive could take a while.
 
B

blobber

Actually the data and the files will not be changing or if so very rarely, so
Ideally I would like to be able to dump an index into a table that I can read
that way I would have the actual path in the database, and could then search
the database rather than the directory structure. If I could do that somehow
that would be great.
 
D

Dirk Goldgar

blobber said:
Actually the data and the files will not be changing or if so very
rarely, so Ideally I would like to be able to dump an index into a
table that I can read that way I would have the actual path in the
database, and could then search the database rather than the
directory structure. If I could do that somehow that would be great.

I'm not sure what you mean by "dump an index into a table that I can
read". If you know where to find the files, why not store that in a
table in advance? If all you need to do is check whether a specific
file exists in a specific folder, you can do that using the Dir()
function. If you really have to search various disks in an attempt to
locate a file, then you try using the Application.FileSearch object to
do it, or else maybe use one method or another of a FileSystemObject (I
don't remember offhand if there's a "FindFile" method), or else code
some rescursive directory search logic. But I can't advise you better
until I understand more clearly what you are really trying to
accomplish.
 
B

blobber

OK let me rephrase hopefully better. I have a table with many filenames.
What I don't have is a table with the location. The location will not
change, the files resides on one of 3 network drives. I am want to do just
what you said which is to store in a table in advance the location of the
file. I was hoping for some kind of easy solution. When I say index I
really mean the file locations. (I call reading and caching the file/folder
locations indexing) So what I am really looking for is a way to create a
table with all the locations of the files so that instead of trying to search
through the network drives I can just have the location in a table and
quickly link the file to the appropriate location.
 
D

Dirk Goldgar

blobber said:
OK let me rephrase hopefully better. I have a table with many
filenames. What I don't have is a table with the location. The
location will not change, the files resides on one of 3 network
drives. I am want to do just what you said which is to store in a
table in advance the location of the file. I was hoping for some
kind of easy solution. When I say index I really mean the file
locations. (I call reading and caching the file/folder locations
indexing) So what I am really looking for is a way to create a table
with all the locations of the files so that instead of trying to
search through the network drives I can just have the location in a
table and quickly link the file to the appropriate location.

So the idea is to run some process that will go through all the
filenames in your table, find out where each one is, and store that
information in the database, either in a new table or by updating the
original filename to include the path? If this is a one-time process,
the fact that the search is very broad and inefficient may not be too
much of a problem. But what if the same filename is found in more than
one location?

Which part of the process do you need help with? It's easy to open a
recordset on your table of filenames and loop through the records. Code
would be similar to this:

Dim rsFiles As DAO.Recordset

Set rsFiles = CurrentDb.OpenRecordset("tblFiles")

With rsFiles
Do Until .EOF
Call FindThisFile(!FileName)
.MoveNext
Loop
.Close
End With

In the above "FindThisFile" would be the name of a function you had
written to find the file and record its location.

Did you look at the help file entry on the FileSearch object?
 
Top