Drive Inventory

M

Mic Diehl

Does anyone know how to display the drive selection dialog box so that a
user can select a drive to search for all .mdb files on a selected drive? I
am trying to develop a utility for my review to search for a user's selected
file extentions on a user's selected drive. I was going to generate an
inventory list of all the .mdb files on their drive.
 
D

Dean

Mic,

Answer provided by Doug Steel a couple of days ago...

To determine all of the documents in the directory, use the Dir function
repeatitively:

Dim strFile As String
Dim strFolder As String

strFolder = "c:\training\documents\"
strFile = Dir(strFolder & "*.*")
Do While Len(strFile) > 0
Debug.Print strFolder & strFile
strFile = Dir()
Loop

To see the files in a list box rather than just printing them to the
Immediate window, you can either store them in a table and have a query
against that table as the RowSource for the list box (with the RowSourceType
set to Table/Query), or you can concatenate them into a string (separating
them with semi-colons) and use that string as the RowSource (with the
RowSourceType set to Value List)

On the other hand, if your intent is to let them select documents from the
list for processing purposes, you could use the standard Windows File Open
dialog. There's complete code to do this as
http://www.mvps.org/access/api/api0001.htm at "The Access Web"
 
M

Mic Diehl

That worked great! I have another question. What if you wanted to search
more than one extention. Like *.mdb and *.doc. How would you do this with
the DIR function?

Thanks!
 
D

Douglas J. Steele

That won't work, Dean.

You either have to return all files and check each one to see whether the
file has one of the extensions of interest, or else use Dir multiple times.
 
D

Dean

Try "*.mbd;doc"
Mic Diehl said:
That worked great! I have another question. What if you wanted to search
more than one extention. Like *.mdb and *.doc. How would you do this with
the DIR function?

Thanks!
 

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