This API code will map a network drive. As always if you wish to put the declare statement in a module then you must remove the
Private from in front of the declare statment.

Add 2 text boxes and a command button on the form, the first textbox is the drive you want to map and the second is the path to the network drive.

================================================================
Option Explicit

Private Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" _
(ByVal lpszNetPath As String, ByVal _
lpszstrPassword As String, ByVal lpszLocalName As String) As Long

Public Sub mapdrive()
Dim strLocalDriveLetter As String
Dim strPassword As String
Dim strNetworkPathName As String

strLocalDriveLetter = Text1 'Local drive letter to be mapped
strPassword = "" 'specify network password if required
strNetworkPathName = Text2 'path to network drive

If WNetAddConnection(strNetworkPathName, strPassword, strLocalDriveLetter) > 0 Then
MsgBox ("An Error occurred mapping the drive")
Else
MsgBox ("Drive successfully mapped!")
End If

End Sub

Private Sub Command1_Click()
mapDrive
End Sub