Access/VBA Library

Network drives

Functions to maintain network drive mappings. For performance reasons it can be wise to make the path to the database a short as possible. A possible solution is to map a drive to the share the database is stored and than link to the database using the drive.

Module: mdlNetworkDrives
' In this case the locaton is stored in a property dbLocation
Dim dbLocation As String
Dim dbDrive As String
If PropertyExists("dbLocation") Then
    ' Get the share of the database location
    dbLocation = CurrentDb.Properties("dbLocation")
    ' Get the current drive mapping for this share
    dbDrive = GetDrive(dbLocation)
    ' If not mapped, then map to first free drive letter
    If dbDrive = "" Then
       dbDrive = GetFreeDrive()
       Call MapShare(dbDrive, dbLocation, False)
    End If
    ' Link tables using the drive share
    Call LinkTable("employee", dbDrive & "\data.accdb")
    Call ShowError("No database location specified")
End If