Results 1 to 7 of 7
  1. #1
    JonMulder is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    24

    objfso.Drives(name).ShareName Not Working on Some Computers

    I have a function that uses File System Object to get the actual network name of a drive. Today, a remote user had it crash when I tried to return the Sharename.

    Code:
    Function GetUNC(LocalPath As String) As String
    MsgBox ("GetUNC Function")
    Dim objFso As FileSystemObject
    Set objFso = New FileSystemObject
    Dim strDrive As String
    Dim strShare As String
    strDrive = objFso.GetDriveName(LocalPath)
    strShare = objFso.Drives(strDrive).ShareName
    GetUNC = Replace(LocalPath, strDrive, strShare)
    Set objFso = Nothing
    End Function
    Specifically, it fails on "strShare = objfso.Drives(strDrive).ShareName" line.



    The incoming LocalPath variable is "P:\GroundwaterDatabases\GWIDS\ImageLocationMap\Gl ennCounty_Book3\21N04W12A002M_LocationMap.jpg"

    I want to change LocalPath to \\nasnro\Projects (i.e., replacing the LocalPath (P) with the network path (\\nasnro\projects).

    Any idea why it doesn't work? It's been doing fine for months on other computers.

    Thanks for any help you can provide!

    Jonathan Mulder
    Engineering Geologist
    California Department of Water Resources

  2. #2
    Dal Jeanis is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Total speculation, but I notice that the original "Path" has the name of a jpg file in it. Does that file even *have* a Sharename property?

  3. #3
    JonMulder is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    24
    Thanks for the reply, but I don't think that's the issue. I just rant it on my computer and it DOES return a value for strShare. BTW, the extra space("Gl enn") is a typo. The actual code contains no space in the string.

  4. #4
    Dal Jeanis is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    k. Well, perhaps you can get the actual error number and message language the next time.

    It can't be a one-shot LAN drop because you would have tested the issue multiple times before posting here.

    I'd next be checking all the operating system details, references and addins of the offending system for differences from the standard, checking 32 bit vs 64 bit settings and so on. However, the Sharename property should be a property of the drive itself, so it would take a pretty big hickey in the local operating system to obscure that.

    I'd also cobble together a paranoid version of the code - display the strDrive, check DriveExists and IsReady, might even code it as Drives.Item(strDrive).ShareName, although that should have no effect. If any of those failed, you'd have more clues.

    There is this little note in the Drive information section of this page http://msdn.microsoft.com/en-us/libr...(v=vs.71).aspx :
    If more than one person can open the project on the network share, you can use an MS-DOS environment variable to give each person a customized mapping for the share.
    Probably not relevant, but it just clunked when I read it.

  5. #5
    JonMulder is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    24
    Dal,

    Thanks for your suggestions on this. I've trimmed down the database to just the few lines of code and it still doesn't work. My remote user get a run-time error "Invalid procedure call or argument".

    What's odd is that the line preceeding the offensice line ("objFso.GetDriveName(LocalPath)) DOES work, so at least the Microsoft Scripting Runtime reference library is working.

    I'll keep mucking with it. Again, thanks for the feedback.
    "

  6. #6
    Dal Jeanis is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    So, what did DriveExists and Isready return when placed between those two lines?

  7. #7
    JonMulder is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    24
    Haven't tried that yet. I'll get back to you.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Can't connect to mdb on some computers
    By udigold1 in forum Access
    Replies: 1
    Last Post: 12-25-2012, 05:07 PM
  2. Replies: 1
    Last Post: 09-20-2012, 03:37 PM
  3. Replies: 2
    Last Post: 08-31-2012, 10:40 AM
  4. Access and NAS drives
    By ekkg in forum Access
    Replies: 1
    Last Post: 07-06-2012, 08:30 AM
  5. Replies: 0
    Last Post: 05-09-2012, 02:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums