blindlemonray
Technical User
Hi, I am trying to dynamically link tables in my database based on the current file path. I have a front end with a separate backend DB. I would like to ensure when the front end is opened it relinks the tables based on the current file path. I am using the code below but getting an error:- "The Microsoft Access database engine cannot open the file <name>. It is already opened exclusively by another user, or you need permission to view its data."
Any help appreciated.
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
With tdf
If .Connect Like ";DATABASE=*" Then
.Connect = ";DATABASE=" & CurrentProject.Path
.RefreshLink
End If
End With
Next
Any help appreciated.
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
With tdf
If .Connect Like ";DATABASE=*" Then
.Connect = ";DATABASE=" & CurrentProject.Path
.RefreshLink
End If
End With
Next