I am using a local 2010 Access Database linked to a MySQL Database using ODBC Driver 5.1.
I want to easily switch from local linked tables on my development PC to a local network database.
The server string localhost or 127.0.0.1 works fine but when changed to 192.168.xxx.xxx then I receive the message
Run-time error '3146'
ODBC --call failed
I want to easily switch from local linked tables on my development PC to a local network database.
The server string localhost or 127.0.0.1 works fine but when changed to 192.168.xxx.xxx then I receive the message
Run-time error '3146'
ODBC --call failed
Code:
Function relinkTables(server As String)
Dim db As DAO.database
Dim tdf As DAO.TableDef
Dim constring, strconnect, port, user, password, database As String
Set db = CurrentDb
port = "3306"
user = "myuser"
password = "mypassword"
database = "mydatabase"
strconnect = "ODBC;DRIVER={MySQl ODBC 5.1 Driver};" & _
"SERVER=" & server & ";" & _
"PORT=" & port & ";" & _
"DATABASE=" & database & ";" & _
"USER=" & user & ";" & _
"PASSWORD=" & password & ";" & _
"OPTION=3;"
For Each tdf In CurrentDb.TableDefs
' check if table is a linked table
If Len(tdf.connect) > 0 Then
tdf.connect = strconnect
tdf.RefreshLink
End If
Next
End Function
Comment