Is this a valid file path?

Lol999

Registered User.
Local time
Today, 13:50
Joined
May 28, 2017
Messages
184
Hi, could just do with some advice on network file paths. I have got an Excel s/s that exports data to a Access d/b via vba behind a button. In development the file path has been c:\ etc etc

Now however the files are to be networked and the filepath I have been given is thus:
office(\\brfile) (o:)/Admin

does this look "correct"?

Cheers, Lol
 
I think you know the answer to this already ... no
 
Morning Ridders, I assume you mean allowing for the fact that the smiley face is actually a colon and a closing bracket?
 
To jump in here - Always only use the UNC path type location in your code, Not a specific assigned drive path. The drive path could be different on different machines. So
Code:
\\YourFileServer\DataFiles\YourDatabase.mdb
will always work from any machine that can get to that network share
Code:
O:\DataFiles\YourDatabase.mdb
Probably won't .
 
following on Minty's comment, heres a helpful function that will convert a mapped drive to a UNC path.
I'd credit the author if I knew who it was.

Code:
Function GetUNC(strMappedDrive As String) As String

    Dim objFso As FileSystemObject
    Set objFso = New FileSystemObject
    Dim strDrive As String
    Dim strShare As String
    
    'Separated the mapped letter from
    'any following sub-folders
    strDrive = objFso.GetDriveName(strMappedDrive)
    
    'find the UNC share name from the mapped letter
    strShare = objFso.Drives(strDrive).ShareName
    
    'The Replace function allows for sub-folders
    'of the mapped drive
    GetUNC = Replace(strMappedDrive, strDrive, strShare)
    
    Set objFso = Nothing    'Destroy the object
    
End Function
 
Thanks colin. I updated my snippets db to credit him.
 
You're welcome -
I've also used that code in the past but like you forgot its source.
I had to do a Google search myself to remind me where it came from.
 

Users who are viewing this thread

Back
Top Bottom