reconnect tables error message

L

Liz James

I am using a function to reconnect attached tables at start up.
The function is Reconnect() by PETER VUKOVIC from Allen Browne’s website.
(Function Reconnect is below.)

If there is an error the following message appears
“Could not find file ‘full path of database front end followed by full path
of back end’.â€

If the user presses Help on the message box, the following message appears
“Could not find file <name>. (Error 3024)
Possible causes:
The specified file does not exist.
You misspelled the file name. Check for missing underscores ( _ ) or other
punctuation, and make sure you did not enter leading spaces.
The network connection has failed or has not been established. “

I would like to be trap the error and display my own custom message.
How could I do this?

********************************
Function Reconnect()

Dim db As Database
Dim source As String
Dim path As String
Dim dbsource As String, i As Integer, j As Integer

Set db = DBEngine.Workspaces(0).Databases(0)


For i = Len(db.Name) To 1 Step -1
If Mid(db.Name, i, 1) = Chr(92) Then
path = Mid(db.Name, 1, i)
Exit For
End If
Next

'Change the path and connect again
For i = 0 To db.TableDefs.Count - 1
If db.TableDefs(i).Connect <> " " Then
source = Mid(db.TableDefs(i).Connect, 11)
'Debug.Print source
For j = Len(source) To 1 Step -1
If Mid(source, j, 1) = Chr(92) Then
dbsource = Mid(source, j + 1, Len(source))
source = Mid(source, 1, j)
If source <> path Then
db.TableDefs(i).Connect = ";Database=" + path +
dbsource
db.TableDefs(i).RefreshLink
'Debug.Print ";Database=" + path + dbsource
End If
Exit For
End If
Next
End If
Next
End Function
*********************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top