Network Drives

  • Thread starter Thread starter Martin
  • Start date Start date
M

Martin

Hello,

Is there any way of listing all the drives that a user is attached to. For
instance I would like to populate a table that has two fields, first field
details the letter assigned to the drive and the second field the path of the
drive itself?

I have searched this and can find how to get the file name and how to map to
a drive but nothing else.

Many thanks in advance,

Martin
 
Do you know how I can get the output from the immediate window into a table
or form so I can display to the user?
 
On Fri, 24 Jul 2009 06:26:01 -0700, Martin

Rather than using debug.print like the sample does you could
concatenate a string (s = s & "whatever"), and in the end assign it to
a textbox (Me.myTextbox = s). It would be elegant if you turned
sListAllDrives into a function that returns the string. Then you can
write:
Me.myTextbox = sListAllDrives()

-Tom.
Microsoft Access MVP
 
Do you know how I can get the output from the immediate window into a table
or form so I can display to the user?





- Show quoted text -

With a table called tblDrives that has two text columns DriveLetter
and DriveType, this will work

Sub sListAllDrives2()
Dim strAllDrives As String, strTmp As String, strDriveType As String
Dim db As DAO.Database, rs As DAO.Recordset
strAllDrives = fGetDrives
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblDrives", dbOpenDynaset)
If strAllDrives <> "" Then
Do
strTmp = Mid$(strAllDrives, 1, InStr(strAllDrives, vbNullChar) -
1)
strAllDrives = Mid$(strAllDrives, InStr(strAllDrives,
vbNullChar) + 1)
strDriveType = fDriveType(strTmp)
If strDriveType = "Network Drive" Then strDriveType = fGetUNCPath
(Left$(strTmp, Len(strTmp) - 1))
With rs
.AddNew
!DriveLetter = strTmp
!DriveType = strDriveType
.Update
End With
Loop While strAllDrives <> ""
End If
Set rs = Nothing
Set db = Nothing
End Sub
 
There is a danger here. Not all users will necessarily have the same drive
mappings. For example you can have a path mapped to M: and another user may
have the same path mapped to P: or may have a different path mapped to M:

If this table is in the back end, you would also have to incude a field to
identify the user.

For this reason, I do not use drive map paths in Access. I use UNC paths
which will be the same for all users. UNC paths are the actual path to the
folder. It is in the form of
\\ServerName\FolderName\SubFolderName
rather than
M:\FolderName\SubfolderName
 
There is a danger here.  Not all users will necessarily have the same drive
mappings.  For example you can have a path mapped to M: and another user may
have the same path mapped to P: or may have a different path mapped to M:

If this table is in the back end, you would also have to incude a field to
identify the user.

For this reason, I do not use drive map paths in Access.  I use UNC paths
which will be the same for all users.  UNC paths are the actual path tothe
folder.  It is in the form of
\\ServerName\FolderName\SubFolderName
rather than
M:\FolderName\SubfolderName
--
Dave Hargis, Microsoft Access MVP






- Show quoted text -

he could always convert the mapped drive reference to a UNC path -
there's code on www.vbnet.mvps.org somewhere...
 
Martin said:
Is there any way of listing all the drives that a user is attached to. For
instance I would like to populate a table that has two fields, first field
details the letter assigned to the drive and the second field the path of the
drive itself?

Do you want to use a table or a list box? If a list box then you can
use a call back function to fill it without using an intermediate
working table.

Tony
 
Back
Top