0

I have this code that I run upon the start of my application. This way we can have a test environment and when we move the front end, it will automatically connect to the correct backend. I use similar code in other applications to change the SQL backend but in this we are changing the Access backend database.

The code looks correct, when I run it using the msgbox, it shows the correct location that it should be updated to and I do not receive an error. However, after the code runs it is still connected to the previous backend (it never changes). What am I missing?

I have looked at other links here and my code looks correct from them. Here is my code:

Private Sub ChangeEnvironments()

    Dim connServer As String
    'MsgBox CurrentDb.TableDefs("LostToCompany").Connect
    Dim currDatabase As String: currDatabase = "MS Access;DATABASE=" & CurrentProject.Path & "\UNDERWRI.MDB"
    'MsgBox CurrentDb.TableDefs("LostToCompany").Connect & vbCrLf & vbCrLf & currDatabase
    CurrentDb.TableDefs("LostToCompany").Connect = currDatabase
    CurrentDb.TableDefs("LostToCompany").RefreshLink
    
End Sub
djblois
  • 963
  • 1
  • 17
  • 52

0 Answers0