[AccessD] Linked Tables - UNC Path

Mitsules, Mark S. (Newport News) Mark.Mitsules at ngc.com
Fri May 7 07:51:09 CDT 2004


Actually my situation is just the opposite.  I know the remote server name,
but the user may have that drive mapped to any letter.  Therefore I would
like to be able to relink automatically using UNC.  I am not comfortable
with the user manually choosing the location of the BE.


Mark


-----Original Message-----
From: Gustav Brock [mailto:gustav at cactus.dk] 
Sent: Friday, May 07, 2004 8:03 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Linked Tables - UNC Path


Hi Mark

> My latest department deployment has tested fine with one exception.  How
can
> I force UNC naming for the linked tables?  I looked over some published
> relinking code, but was not prepared to drop in any code that could
possibly
> involve user intervention.

This may not be that easy but have a look here:

   http://www.mvps.org/vb/samples.htm#UncName


For remote drive letters only, this module could be used.

<code>

Option Compare Database
Option Explicit

Private Const UNIVERSAL_NAME_INFO_LEVEL As Long = &H1&

Private Declare Function WNetGetUniversalName Lib "mpr.dll" Alias
"WNetGetUniversalNameA" ( _
  ByVal lpLocalPath As String, _
  ByVal dwInfoLevel As Long, _
  ByRef lpBuffer As Any, _
  ByRef lpBufferSize As Long) _
  As Long

Private Type UNIVERSAL_NAME_INFO
  lpUniversalName As String * &H400&
End Type

Public Function GetUniversalPath( _
  ByVal strDrivePath As String) _
  As String

' Get UNC path from remote drive letter or drive letter and file name.
' Empty string is returned for local or non-mapped drive letters.
' Remote path is *not* validated except for the drive letter.
'
' Example:

'   s:\docs\letter.txt
'
' may return
'
'   \\FS1\SYS\DATA\docs\letter.txt
'
' 2002-03-25. Cactus Data ApS, CPH.
  
  Dim typBuffer   As UNIVERSAL_NAME_INFO
  Dim lngBuffer   As Long
  Dim strPath     As String
  
  ' Obtain needed buffer size.
  Call WNetGetUniversalName(strDrivePath, UNIVERSAL_NAME_INFO_LEVEL, 0,
lngBuffer)
  ' Retrieve UNC info.
  Call WNetGetUniversalName(strDrivePath, UNIVERSAL_NAME_INFO_LEVEL,
typBuffer, lngBuffer)
  
  ' Extract UNC path from mixed buffer.
  strPath = typBuffer.lpUniversalName
  strPath = Mid$(strPath, InStr(strPath, vbNullChar) + 1)
  strPath = Left$(strPath, InStr(strPath, vbNullChar) - 1)

  GetUniversalPath = strPath

End Function

</code>

Beware of line breaks.

/gustav

-- 
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list