connort1234
New member
- Local time
- Today, 18:50
- Joined
- Jun 27, 2016
- Messages
- 3
I have created code to relink my database to the back end from a form. The form has a field linked to a table that stores the back end file path, it uses a browse button to locate the browse button and then a Re-Link button to relink the tables to the back end at the new location.
The code works perfectly in Access and I can relink tables no problem, but when I open the database in access runtime (on another computer) and try run the code, it gives a runtime error and closes the database. The back end sits on a server and I am trying to get the tables to relink to the back end from a runtime version of access.
This is the code I used:
The code works perfectly in Access and I can relink tables no problem, but when I open the database in access runtime (on another computer) and try run the code, it gives a runtime error and closes the database. The back end sits on a server and I am trying to get the tables to relink to the back end from a runtime version of access.
This is the code I used:
Code:
Dim Dbs As Database
Dim Tdf As TableDef
Dim Tdfs As TableDefs
Dim NewPathname As String
Set Dbs = CurrentDb
Set Tdfs = Dbs.TableDefs
NewPathname = DFirst("[BackEndFilePath]", "Settings")
For Each Tdf In Tdfs
If Tdf.SourceTableName <> "" Then
Tdf.Connect = ";DATABASE=" & NewPathname
Tdf.RefreshLink
End If
Next
MsgBox "All the application tables have been relinked to the database at " & NewPathname & " Thank you...", vbInformation, "Tables ReLinked"