1 1 1 1 1 1 1 1 1 1 Rating 0.00 (0 Votes)

Nur für 32Bit Office Versionen

Problemstellung:

Wie kann ich feststellen ob eine DB Lokal oder im Netzwerk geöffnet wurde?
Für MS-Access00-07

Public Declare Function WNetGetConnection Lib "mpr.dll" _
    Alias "WNetGetConnectionA" _
    (ByVal lpszLocalName As String, _
    ByVal lpszRemoteName As String, _
    cbRemoteName As Long) As Long
    
Function IsNetworkDB(strPath As String) As Boolean
    Dim strPath As String
    Dim strDrive As String, strResult As String
    Dim R As Long
    IsNetworkDB = False
    strDrive = Left$(strPath, 2)
    If strDrive = "\\" Then
        IsNetworkDB = True
        Exit Function
    End If
    strResult = Space$(250)
    R = WNetGetConnection(strDrive & vbNullChar, _
        strResult, _
        Len(strResult))
    If R = 0 And Trim$(strResult) <> "" Then
        IsNetworkDB = True
    End If
End Function

Aufruf:

Dim bNetState As Boolean
bNetState = IsNetworkDB(CurrentDb.Name)

Das Ergebnis:

Die Variable bNetState nimmt den Wert True an wenn die DB im Netz geöffnet wurde
und False wenn DB Lokal geöffnet ist.

 

Ähnliche Artikel