Forum Discussion
OfekDerin
Nov 20, 2020Copper Contributor
MS Access Stored on a Cloud
Hi! I've built an access application for my organization to use managing project records. The situation is that the only one that have promotions to edit the data in the tables is me, and many o...
- Nov 22, 2020
We found a solution for our problem:
We used the Application.CurrentProject.Path to get the file location and then added the path to the sub folder with the DB file.
Then we used- Set dbs = CurrentDb()
and for each table we did:
dbs.TableDefs(strTable).Connect = ";DATABASE=" & LnkDataBase
dbs.TableDefs(strTable).RefreshLinkFull solution:
Dim LnkDataBase As String LnkDataBase = Application.CurrentProject.Path & "\rest of path\DB.accdb" Dim dbs As DAO.Database Dim tdf As DAO.TableDef Dim strTable As String Set dbs = CurrentDb() For Each tdf In dbs.TableDefs If Len(tdf.Connect) > 1 Then 'Only relink linked tables If tdf.Connect <> ";DATABASE=" & LnkDataBase Then 'only relink tables if the are not linked right If Left(tdf.Connect, 4) <> "ODBC" Then 'Don't want to relink any ODBC tables strTable = tdf.Name dbs.TableDefs(strTable).Connect = ";DATABASE=" & LnkDataBase dbs.TableDefs(strTable).RefreshLink End If End If End If Next tdf
It appeares it solved it.
OfekDerin
Nov 22, 2020Copper Contributor
We found a solution for our problem:
We used the Application.CurrentProject.Path to get the file location and then added the path to the sub folder with the DB file.
Then we used- Set dbs = CurrentDb()
and for each table we did:
dbs.TableDefs(strTable).Connect = ";DATABASE=" & LnkDataBase
dbs.TableDefs(strTable).RefreshLink
Full solution:
Dim LnkDataBase As String
LnkDataBase = Application.CurrentProject.Path & "\rest of path\DB.accdb"
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim strTable As String
Set dbs = CurrentDb()
For Each tdf In dbs.TableDefs
If Len(tdf.Connect) > 1 Then 'Only relink linked tables
If tdf.Connect <> ";DATABASE=" & LnkDataBase Then 'only relink tables if the are not linked right
If Left(tdf.Connect, 4) <> "ODBC" Then 'Don't want to relink any ODBC tables
strTable = tdf.Name
dbs.TableDefs(strTable).Connect = ";DATABASE=" & LnkDataBase
dbs.TableDefs(strTable).RefreshLink
End If
End If
End If
Next tdf
It appeares it solved it.