drive list

DaveMere

Registered User.
Local time
Today, 16:44
Joined
Sep 18, 2002
Messages
63
Hi,

Does anyone know if Access has a built-in control that allows users to scan the directory structure of their PC? Similar to the DriveListBox and DirListBox controls in VB6? If so, how might I get access to it?

Thanks

Davemere
 
OPen a module, goto Tools -> References and select Microsoft Scripting Runtime.

This gives you access to more tools such as the Dictionary object and the one we're interest in: the FileSystemObject.

You can now use that to navigate around drives, folders, and subfolders.

i.e.

Code:
Public Function ListDrives()

    Dim fso As FileSystemObject
    Dim drv As Drive
    
    Set fso = New FileSystemObject

    For Each drv In fso.Drives
        Debug.Print drv.Path
    Next drv
    
    Set drv = Nothing
    Set fso = Nothing

End Function ' ListDrives
 
I see. Thanks SJ. That will come in most useful for scanning the drives myself in code, and I can see how I could present a list of available drives on a form in say, a list box. However I can't seem to view any of the directory structure beneath drive letters using this method.

What would also be useful would be a control via which my users could browse the full directory structure available to them, and choose the specific directory into which they wish to save a file (one of the functions of my system is to create a new file). Do you know of any controls by which I could do that?

many thanks

Dave
 
DaveMere said:
I can't seem to view any of the directory structure beneath drive letters using this method.

You can create Folder objects and navigate through the drive's RootFolder's files and subfolders.

Code:
Dim fld As Folder

For Each fld In drv.RootFolder.Subfolders


Next fld
 

Users who are viewing this thread

Back
Top Bottom