Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 2043 can't find database

Status
Not open for further replies.

GPM4663

Technical User
Aug 9, 2001
165
GB
Hi Everyone,
I have a fe/be database with the backend on a LAN. Whenever I restart my computer and open the database the links to my backend are still present but appear to be "severed". I have to go in manually and refresh all the links before it works again.

I set up some code to delete the links and create new links on start up using Docmd.Transfer database which works beautifully until I restart my computer when I get a error 2043 can't find database "L://blah blah".

For some reason access can't see the network when I restart my computer. Is there anyway for me to force access to refresh the link with the network when it opens.
I've tried using the UNC notation for the file path also and have been using .mdb at the end of the filepath.

I have all the correct references for libraries and am completely stumped on this one. I'd appreciate any advice anyone has.

Many thanks in advance,

GPM
 
GPM

When you boot the network drive is re-connected? Before opennig access check that with explorer. If not do the mapping and make sure you select the re-connect at logon option.
 
Hi JerryKlmns,
Yes the drive is already there on startup, thats the strange thing. If I go into access and use the linked table manager I can relink the tables without a problem.
Strange huh?

thanks

GPM


 

Strange: Not. Annoying: Yes.

What if you force the acces mdb to execute a simple dir statement to wake up mapped network drive? Or do a check on your network?
 
Hmmm, what kind of dir statement would you recommend that would be quick but like you say could wake the network up.

thanks

GPM
 
OK, tried that and now it comes up with 52 bad file name or number. Is there any other way to refresh a network link?

Thanks again

GPM
 
GPM

The following code is trying to map a network drive + path to a specific letter. If that is not available then mapps to a new free one. Might need some modifications but give it a try
Code:
Private Sub Act1(strServer As String, strFolder As String, strMapLetter )

Dim objWshNetwork As Object
Dim objCheckDrive As Object
Dim objRST As Object
Dim blnMapLetterFound As Boolean
Dim blnMapServerFound As Boolean
Dim blnFreeLetterFound As Boolean
Dim i As Long
Dim strMappedLetter As String
Dim lCheckDriveCounts As Long

On Error GoTo Act_Err

Set objWshNetwork = CreateObject("WScript.Network")
Set objCheckDrive = objWshNetwork.EnumNetworkDrives()
Set objRST = CreateObject("ADODB.Recordset")
With objRST
    .CursorLocation = 3 'adUseClient
    .CursorType = 2 'adOpenSattic
    .LockType = 3 'adLockOptimistic
    .Fields.Append "MapLetter", 200, 2 'adVarChar
    .Fields.Append "ThePath", 200, 255 'adVarChar
    .Open
    lCheckDriveCounts = objCheckDrive.Count
    For i = 0 To lCheckDriveCounts - 1 Step 2
        If Trim(UCase(objCheckDrive.Item(i)) & "") <> "" Then
            .AddNew
            .Fields(0) = objCheckDrive.Item(i)
            .Fields(1) = UCase(objCheckDrive.Item(i + 1))
            .Update
        End If
    Next i
    .Sort = "MapLetter"
    .Filter = "MapLetter = '" & strMapLetter & ":'"
    If .EOF And .BOF Then
        blnMapLetterFound = False
        strMappedLetter = strMapLetter & ":"
    Else
        blnMapLetterFound = True
    End If
    .Filter = ""
    .Filter = "ThePath = '" & UCase(strServer & strFolder) & "'"
    If Not (.EOF And .BOF) Then
        strMappedLetter = objCheckDrive.Item(i)
        blnMapServerFound = True
    End If
    .Filter = ""
    Select Case True
        Case blnMapLetterFound = True And blnMapServerFound = False
            i = Asc(strMapLetter)
            While Not blnFreeLetterFound And i <= Asc("Z")
                .Filter = "MapLetter = '" & Chr(i) & ":'"
                If .EOF And .BOF Then
                    strMappedLetter = Chr(i) & ":"
                    blnFreeLetterFound = True
                End If
                .Filter = ""
                i = i + 1
            Wend
            objWshNetwork.MapNetworkDrive strMappedLetter, strServer & strFolder, True
        
        Case blnMapServerFound = True
            objWshNetwork.RemoveNetworkDrive strMappedLetter, True, True
            objWshNetwork.MapNetworkDrive strMappedLetter, strServer & strFolder, True
        
        Case blnFreeLetterFound = True And blnMapServerFound = True
            objWshNetwork.RemoveNetworkDrive strMappedLetter, True, True
            objWshNetwork.MapNetworkDrive strMappedLetter, strServer & strFolder, True
        
        Case blnMapLetterFound = False And blnMapServerFound = False
            objWshNetwork.MapNetworkDrive strMapLetter & ":", strServer & strFolder, True
        
        Case Else
    End Select
    MsgBox "Succesfully mapped the server.", vbInformation + vbOKOnly, "Mapping drive"
End With

Act_Exit:
    If Not objRST Is Nothing Then
        If objRST.State = 1 Then objRST.Close 'adStateOpen
        Set objRST = Nothing
    End If
    Set objCheckDrive = Nothing
    Set objWshNetwork = Nothing
    Exit Sub

Act_Err:
    MsgBox "Attention! Critical error while mapping the server." & vbCrLf _
         & "No : " & Err.Number & vbCrLf _
         & "Description : " & Err.Description, vbSystemModal + vbCritical + vbOKOnly, _
           "Mapping drive"
    Resume Act_Exit

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top