I have been tearing my hair out with this so I hope that someone can help.
I have an Access front end linking to MySQL server tables, via connection string (dsn-less connection). I regularly change the username and password and refresh the connection using this code:-
Dim Dbs As Database
Dim Tdf As TableDef
Dim Tdfs As TableDefs
Set Dbs = CurrentDb
Set Tdfs = Dbs.TableDefs
For Each Tdf In Tdfs
If Tdf.SourceTableName <> "" Then
Tdf.Connect = "ODBC;Driver={MySQL ODBC 5.1 Driver};Server=MyServer.co.uk;Database=myDataBase; User=myUsername;Password=myPassword;Option=0;"
Tdf.RefreshLink
End If
Next
That all works fine, but I now want to use different connection strings. I can get different connection strings to appear in the Table Properties, but when I try to open any table, it always the last connection string that was reset.
For example, if I use
If Tdf.SourceTableName = "SomeTable" Then
Tdf.connect = StrTwo
Tdf.RefreshLink
all the tables will use StrTwo, no matter what the Table Properties say.
Hope that's clear
Ian
I have an Access front end linking to MySQL server tables, via connection string (dsn-less connection). I regularly change the username and password and refresh the connection using this code:-
Dim Dbs As Database
Dim Tdf As TableDef
Dim Tdfs As TableDefs
Set Dbs = CurrentDb
Set Tdfs = Dbs.TableDefs
For Each Tdf In Tdfs
If Tdf.SourceTableName <> "" Then
Tdf.Connect = "ODBC;Driver={MySQL ODBC 5.1 Driver};Server=MyServer.co.uk;Database=myDataBase; User=myUsername;Password=myPassword;Option=0;"
Tdf.RefreshLink
End If
Next
That all works fine, but I now want to use different connection strings. I can get different connection strings to appear in the Table Properties, but when I try to open any table, it always the last connection string that was reset.
For example, if I use
If Tdf.SourceTableName = "SomeTable" Then
Tdf.connect = StrTwo
Tdf.RefreshLink
all the tables will use StrTwo, no matter what the Table Properties say.
Hope that's clear
Ian