Good Morning,
I am in the process of converting some DAO code to ADO. I have a routine that refreshes links as below:
The strange thing is that when executing the function the code gets to:
an error is raised but the error description is "".
Can anyone see what is the error?
Thanks,
Rewdee
P.s. Maybe the error has something to do with I'm writing this code in AccessXP and the backend database is Access 97.
I am in the process of converting some DAO code to ADO. I have a routine that refreshes links as below:
Code:
Function RefreshLinks() As Boolean
Dim sDBPath As String
Dim strMsg As String
Dim cat As New ADOX.Catalog
Dim tdfLocal As New ADOX.Table
Const cFILE_NOT_FOUND = vbObjectError + 1000
sDBPath = getBackendDB
cat.ActiveConnection = CurrentProject.Connection
On Local Error GoTo RefreshLinks_Err
'first make sure we have a valid path to remote db
If Len(Dir(sDBPath)) = 0 Then Err.Raise cFILE_NOT_FOUND
'iterate through looking for linked tables
For Each tdfLocal In cat.Tables
If tdfLocal.Type = "LINK" Then
tdfLocal.Properties("JET OLEDB:Create Link") = False
tdfLocal.Properties("JET OLEDB:Link Data Source") = sDBPath
tdfLocal.Properties("JET OLEDB:Create Link") = True
End If
Next
RefreshLinks = True
RefreshLinks_End:
Set tdfLocal = Nothing
Set cat = Nothing
Exit Function
RefreshLinks_Err:
RefreshLinks = False
Select Case Err
Case 3059:
Case cFILE_NOT_FOUND:
LogMessage ("The Path to file: " & sDBPath & ", couldn't link tables.")
Case Else:
strMsg = "Error Information..." & vbCrLf & vbCrLf
strMsg = strMsg & "Function: RefreshLinks" & vbCrLf
strMsg = strMsg & "Description: " & Err.Description & vbCrLf
strMsg = strMsg & "Error #: " & Format$(Err.Number) & vbCrLf
LogMessage strMsg
End Select
Resume RefreshLinks_End
End Function
The strange thing is that when executing the function the code gets to:
Code:
tdfLocal.Properties("JET OLEDB:Create Link") = False
Can anyone see what is the error?
Thanks,
Rewdee
P.s. Maybe the error has something to do with I'm writing this code in AccessXP and the backend database is Access 97.