Reputation: 4126
We have an access application (split into frontend and backend) that uses the following code to relink tables:
Private Function ReconnectTables() As Boolean
On Error Resume Next
Dim tdf As DAO.TableDef
Dim dbs As DAO.Database
Dim strPath As String
Dim strConnect As String
Set dbs = CurrentDb
strConnect = "\\dfs\prd\departmentX\DepartmentalApplicationX_be.accdb"
For Each tdf In dbs.TableDefs
If tdf.Connect <> "" Then
tdf.Connect = ";DATABASE=" & strConnect
tdf.RefreshLink
End If
Next
Set dbs = Nothing
If Err.Number = 0 Then ReconnectTables = True
End Function
This works fine when used by a single user, but hangs (takes approx. 5 minutes ) as soon as a second user tries to access this.
Is there any way I can avoid this? It looks as if I have two options:
Thanks for sharing your wisdom !
Upvotes: 2
Views: 562
Reputation: 20044
Try this:
Set dbs = CurrentDb
strConnect = ";DATABASE=\\dfs\prd\departmentX\DepartmentalApplicationX_be.accdb"
For Each tdf In dbs.TableDefs
If tdf.Connect <> "" and tdf.Connect<> strConnect Then
tdf.Connect = strConnect
tdf.RefreshLink
End If
Next
So the reconnect should only happen if necessary.
Upvotes: 2